ENT-2116: handle amqp client remote error, added test (#3636)

* ENT-2116: handle amqp client remote error, added test

* ENT: 2116 rename test, added logging

* ENT-2116: rename test to indicate its purpose
This commit is contained in:
bpaunescu
2018-07-18 16:07:42 +01:00
committed by GitHub
parent 08b5cb6d5f
commit 53b398a460
2 changed files with 37 additions and 0 deletions

View File

@ -66,6 +66,8 @@ internal class ConnectionStateMachine(private val serverMode: Boolean,
private fun logInfoWithMDC(msg: String) = withMDC { log.info(msg) }
private fun logWarnWithMDC(msg: String, ex: Throwable? = null) = withMDC { log.warn(msg, ex) }
private fun logErrorWithMDC(msg: String, ex: Throwable? = null) = withMDC { log.error(msg, ex) }
val connection: Connection
@ -308,6 +310,16 @@ internal class ConnectionStateMachine(private val serverMode: Boolean,
}
}
override fun onLinkRemoteClose(e: Event) {
val link = e.link
if(link.remoteCondition != null) {
logWarnWithMDC("Connection closed due to error on remote side: `${link.remoteCondition.description}`")
transport.condition = link.condition
transport.close_tail()
transport.pop(Math.max(0, transport.pending())) // Force generation of TRANSPORT_HEAD_CLOSE (not in C code)
}
}
override fun onLinkFinal(event: Event) {
val link = event.link
if (link is Sender) {