diff --git a/akka-remote/src/main/scala/akka/remote/Endpoint.scala b/akka-remote/src/main/scala/akka/remote/Endpoint.scala index f3f922cd92..292b535c7f 100644 --- a/akka-remote/src/main/scala/akka/remote/Endpoint.scala +++ b/akka-remote/src/main/scala/akka/remote/Endpoint.scala @@ -431,8 +431,8 @@ private[remote] class EndpointWriter( throw reason } - private def publishAndStay(reason: Throwable): State = { - publishError(reason) + private def logAndStay(reason: Throwable): State = { + log.error(reason, "Transient association error (association remains live)") stay() } @@ -511,7 +511,7 @@ private[remote] class EndpointWriter( remoteMetrics.logPayloadBytes(msg, pduSize) if (pduSize > transport.maximumPayloadBytes) { - publishAndStay(new OversizedPayloadException(s"Discarding oversized payload sent to ${recipient}: max allowed size ${transport.maximumPayloadBytes} bytes, actual size of encoded ${msg.getClass} was ${pdu.size} bytes.")) + logAndStay(new OversizedPayloadException(s"Discarding oversized payload sent to ${recipient}: max allowed size ${transport.maximumPayloadBytes} bytes, actual size of encoded ${msg.getClass} was ${pdu.size} bytes.")) } else if (h.write(pdu)) { stay() } else { @@ -522,7 +522,7 @@ private[remote] class EndpointWriter( throw new EndpointException("Internal error: Endpoint is in state Writing, but no association handle is present.") } } catch { - case e: NotSerializableException ⇒ publishAndStay(e) + case e: NotSerializableException ⇒ logAndStay(e) case e: EndpointException ⇒ publishAndThrow(e) case NonFatal(e) ⇒ publishAndThrow(new EndpointException("Failed to write message to the transport", e)) } @@ -705,8 +705,9 @@ private[remote] class EndpointReader( } case InboundPayload(oversized) ⇒ - publishError(new OversizedPayloadException(s"Discarding oversized payload received: " + - s"max allowed size [${transport.maximumPayloadBytes}] bytes, actual size [${oversized.size}] bytes.")) + log.error(new OversizedPayloadException(s"Discarding oversized payload received: " + + s"max allowed size [${transport.maximumPayloadBytes}] bytes, actual size [${oversized.size}] bytes."), + "Transient error while reading from association (association remains live)") case StopReading(writer) ⇒ saveState() diff --git a/akka-remote/src/test/scala/akka/remote/RemotingSpec.scala b/akka-remote/src/test/scala/akka/remote/RemotingSpec.scala index fcaf62247e..4042a0d166 100644 --- a/akka-remote/src/test/scala/akka/remote/RemotingSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemotingSpec.scala @@ -466,9 +466,9 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D "drop unserializable messages" in { object Unserializable - verifySend(Unserializable) { - expectMsgPF(1.second) { - case AssociationErrorEvent(_: NotSerializableException, _, _, _) ⇒ () + EventFilter[NotSerializableException](pattern = ".*No configured serialization.*", occurrences = 1).intercept { + verifySend(Unserializable) { + expectNoMsg(1.second) // No AssocitionErrorEvent should be published } } } @@ -483,18 +483,18 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D "drop sent messages over payload size" in { val oversized = byteStringOfSize(maxPayloadBytes + 1) - verifySend(oversized) { - expectMsgPF(1.second) { - case AssociationErrorEvent(e: OversizedPayloadException, _, _, _) if e.getMessage.startsWith("Discarding oversized payload sent") ⇒ () + EventFilter[OversizedPayloadException](pattern = ".*Discarding oversized payload sent.*", occurrences = 1).intercept { + verifySend(oversized) { + expectNoMsg(1.second) // No AssocitionErrorEvent should be published } } } "drop received messages over payload size" in { // Receiver should reply with a message of size maxPayload + 1, which will be dropped and an error logged - verifySend(maxPayloadBytes + 1) { - expectMsgPF(1.second) { - case AssociationErrorEvent(e: OversizedPayloadException, _, _, _) if e.getMessage.startsWith("Discarding oversized payload received") ⇒ () + EventFilter[OversizedPayloadException](pattern = ".*Discarding oversized payload received.*", occurrences = 1).intercept { + verifySend(maxPayloadBytes + 1) { + expectNoMsg(1.second) // No AssocitionErrorEvent should be published } } }