Pub/Sub are now closed when exceptions are thrown
This commit is contained in:
parent
d408493907
commit
e74f4a4e10
@ -195,13 +195,13 @@ dependencies {
|
||||
|
||||
// https://github.com/MicroUtils/kotlin-logging
|
||||
api("io.github.microutils:kotlin-logging:3.0.4")
|
||||
api("org.slf4j:slf4j-api:2.0.4")
|
||||
api("org.slf4j:slf4j-api:2.0.5")
|
||||
|
||||
|
||||
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("ch.qos.logback:logback-classic:1.4.4")
|
||||
testImplementation("ch.qos.logback:logback-classic:1.4.5")
|
||||
}
|
||||
|
||||
publishToSonatype {
|
||||
|
@ -499,7 +499,7 @@ open class Client<CONNECTION : Connection>(
|
||||
isReliable = reliable
|
||||
)
|
||||
|
||||
type = "${udpConnection.type} '$remoteAddressString:${config.port}'"
|
||||
type = "${udpConnection.type} '$remoteAddressPrettyString:${config.port}'"
|
||||
|
||||
// throws a ConnectTimedOutException if the client cannot connect for any reason to the server handshake ports
|
||||
udpConnection.build(aeronDriver, logger)
|
||||
|
@ -160,6 +160,7 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||
}
|
||||
|
||||
// called from the connect thread
|
||||
// when exceptions are thrown, the handshake pub/sub will be closed
|
||||
fun hello(handshakeConnection: MediaDriverClient, connectionTimeoutSec: Int) : ClientConnectionInfo {
|
||||
failedException = null
|
||||
connectKey = getSafeConnectKey()
|
||||
@ -206,11 +207,17 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||
|
||||
val failedEx = failedException
|
||||
if (failedEx != null) {
|
||||
subscription.close()
|
||||
publication.close()
|
||||
|
||||
ListenerManager.cleanStackTraceInternal(failedEx)
|
||||
throw failedEx
|
||||
}
|
||||
|
||||
if (connectionHelloInfo == null) {
|
||||
subscription.close()
|
||||
publication.close()
|
||||
|
||||
val exception = ClientTimedOutException("[$aeronLogInfo] Waiting for registration response from server")
|
||||
ListenerManager.cleanStackTraceInternal(exception)
|
||||
throw exception
|
||||
@ -220,6 +227,7 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||
}
|
||||
|
||||
// called from the connect thread
|
||||
// when exceptions are thrown, the handshake pub/sub will be closed
|
||||
fun done(handshakeConnection: MediaDriverClient, connectionTimeoutSec: Int) {
|
||||
val registrationMessage = HandshakeMessage.doneFromClient(connectKey,
|
||||
handshakeConnection.port+1,
|
||||
@ -272,6 +280,8 @@ internal class ClientHandshake<CONNECTION: Connection>(
|
||||
|
||||
val failedEx = failedException
|
||||
if (failedEx != null) {
|
||||
handshakeConnection.subscription.close()
|
||||
handshakeConnection.publication.close()
|
||||
throw failedEx
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user