Merge pull request #1573 from drewhk/wip-3475-always-log-error-remoting-drewhk

Error level remoting events are logged by default #3475
This commit is contained in:
Roland Kuhn 2013-07-04 04:58:11 -07:00
commit 23060f1d03
2 changed files with 16 additions and 15 deletions

View file

@ -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()

View file

@ -466,9 +466,9 @@ class RemotingSpec extends AkkaSpec(RemotingSpec.cfg) with ImplicitSender with D
"drop unserializable messages" in {
object Unserializable
EventFilter[NotSerializableException](pattern = ".*No configured serialization.*", occurrences = 1).intercept {
verifySend(Unserializable) {
expectMsgPF(1.second) {
case AssociationErrorEvent(_: NotSerializableException, _, _, _) ()
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)
EventFilter[OversizedPayloadException](pattern = ".*Discarding oversized payload sent.*", occurrences = 1).intercept {
verifySend(oversized) {
expectMsgPF(1.second) {
case AssociationErrorEvent(e: OversizedPayloadException, _, _, _) if e.getMessage.startsWith("Discarding oversized payload sent") ()
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
EventFilter[OversizedPayloadException](pattern = ".*Discarding oversized payload received.*", occurrences = 1).intercept {
verifySend(maxPayloadBytes + 1) {
expectMsgPF(1.second) {
case AssociationErrorEvent(e: OversizedPayloadException, _, _, _) if e.getMessage.startsWith("Discarding oversized payload received") ()
expectNoMsg(1.second) // No AssocitionErrorEvent should be published
}
}
}