Ignore data request message success or failure after a timeout

This commit is contained in:
Ivan Vilata-i-Balaguer 2016-05-05 10:40:59 +02:00
parent 00df057e09
commit 846cdb743f

View file

@ -80,18 +80,26 @@ public class GetDataRequestHandler {
Futures.addCallback(future, new FutureCallback<Connection>() { Futures.addCallback(future, new FutureCallback<Connection>() {
@Override @Override
public void onSuccess(Connection connection) { public void onSuccess(Connection connection) {
log.trace("Send DataResponse to {} succeeded. getDataResponse={}", if (!stopped) {
connection.getPeersNodeAddressOptional(), getDataResponse); log.trace("Send DataResponse to {} succeeded. getDataResponse={}",
cleanup(); connection.getPeersNodeAddressOptional(), getDataResponse);
listener.onComplete(); cleanup();
listener.onComplete();
} else {
log.trace("We have stopped already. We ignore that networkNode.sendMessage.onSuccess call.");
}
} }
@Override @Override
public void onFailure(@NotNull Throwable throwable) { public void onFailure(@NotNull Throwable throwable) {
String errorMessage = "Sending getDataRequest to " + connection + if (!stopped) {
" failed. That is expected if the peer is offline. getDataResponse=" + getDataResponse + "." + String errorMessage = "Sending getDataRequest to " + connection +
"Exception: " + throwable.getMessage(); " failed. That is expected if the peer is offline. getDataResponse=" + getDataResponse + "." +
handleFault(errorMessage, CloseConnectionReason.SEND_MSG_FAILURE, connection); "Exception: " + throwable.getMessage();
handleFault(errorMessage, CloseConnectionReason.SEND_MSG_FAILURE, connection);
} else {
log.trace("We have stopped already. We ignore that networkNode.sendMessage.onFailure call.");
}
} }
}); });
} }