Do not let exceptions in post-rejection json trigger close loops
This commit is contained in:
@@ -146,29 +146,31 @@ 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]
|
||||||
dais.readFully(payload)
|
dais.readFully(payload)
|
||||||
|
|
||||||
JsonSlurper json = new JsonSlurper()
|
JsonSlurper json = new JsonSlurper()
|
||||||
json = json.parse(payload)
|
json = json.parse(payload)
|
||||||
|
|
||||||
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")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
json.tryHosts.asList().each {
|
||||||
|
Destination suggested = new Destination(it)
|
||||||
|
eventBus.publish(new HostDiscoveredEvent(destination: suggested))
|
||||||
|
}
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
log.warning("Problem parsing post-rejection payload",ignore)
|
||||||
|
} finally {
|
||||||
|
// the end
|
||||||
e.closeQuietly()
|
e.closeQuietly()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json.tryHosts.asList().each {
|
|
||||||
Destination suggested = new Destination(it)
|
|
||||||
eventBus.publish(new HostDiscoveredEvent(destination: suggested))
|
|
||||||
}
|
|
||||||
|
|
||||||
// the end
|
|
||||||
e.closeQuietly()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user