Do not let exceptions in post-rejection json trigger close loops

This commit is contained in:
Zlatin Balevsky
2018-07-25 20:54:52 +01:00
parent 7a77b88d49
commit ac8d554332

View File

@@ -146,9 +146,9 @@ class ConnectionEstablisher {
} }
log.info("connection to ${e.destination.toBase32()} rejected") log.info("connection to ${e.destination.toBase32()} rejected")
// can publish the rejected event now
eventBus.publish(new ConnectionEvent(endpoint: e, incoming: false, status: ConnectionAttemptStatus.REJECTED))
eventBus.publish(new ConnectionEvent(endpoint: e, incoming: false, status: ConnectionAttemptStatus.REJECTED))
try {
DataInputStream dais = new DataInputStream(e.inputStream) DataInputStream dais = new DataInputStream(e.inputStream)
int payloadSize = dais.readUnsignedShort() int payloadSize = dais.readUnsignedShort()
byte[] payload = new byte[payloadSize] byte[] payload = new byte[payloadSize]
@@ -159,7 +159,6 @@ class ConnectionEstablisher {
if (json.tryHosts == null) { if (json.tryHosts == null) {
log.warning("post-rejection json didn't contain hosts to try") log.warning("post-rejection json didn't contain hosts to try")
e.closeQuietly()
return return
} }
@@ -167,8 +166,11 @@ class ConnectionEstablisher {
Destination suggested = new Destination(it) Destination suggested = new Destination(it)
eventBus.publish(new HostDiscoveredEvent(destination: suggested)) eventBus.publish(new HostDiscoveredEvent(destination: suggested))
} }
} catch (Exception ignore) {
log.warning("Problem parsing post-rejection payload",ignore)
} finally {
// the end // the end
e.closeQuietly() e.closeQuietly()
} }
}
} }