mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 18:22:12 +01:00
nonetty: Print fewer stack traces on errors. Handle failure of initial connect call.
This commit is contained in:
parent
68a614a33b
commit
4b035535e2
@ -691,7 +691,13 @@ public class PeerGroup extends AbstractIdleService implements TransactionBroadca
|
||||
peer.setMinProtocolVersion(vMinRequiredProtocolVersion);
|
||||
pendingPeers.add(peer);
|
||||
|
||||
channels.openConnection(address, peer);
|
||||
try {
|
||||
channels.openConnection(address, peer);
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to connect to " + address + ": " + e.getMessage());
|
||||
handlePeerDeath(peer);
|
||||
return null;
|
||||
}
|
||||
peer.setSocketTimeout(vConnectTimeoutMillis);
|
||||
// When the channel has connected and version negotiated successfully, handleNewPeer will end up being called on
|
||||
// a worker thread.
|
||||
|
@ -211,7 +211,7 @@ class ConnectionHandler implements MessageWriteTarget {
|
||||
} catch (Exception e) {
|
||||
// This can happen eg if the channel closes while the thread is about to get killed
|
||||
// (ClosedByInterruptException), or if handler.parser.receiveBytes throws something
|
||||
log.error("Error handling SelectionKey", e);
|
||||
log.error("Error handling SelectionKey: " + e.getMessage());
|
||||
if (handler != null)
|
||||
handler.closeConnection();
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ public class NioClientManager extends AbstractExecutionThreadService implements
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Calling sc.socket().getRemoteSocketAddress() here throws an exception, so we can only log the error itself
|
||||
log.error("Failed to connect with exception", e);
|
||||
log.error("Failed to connect with exception: {}", e.getMessage());
|
||||
handler.closeConnection();
|
||||
} catch (CancelledKeyException e) { // There is a race to get to interestOps after finishConnect() which may cause this
|
||||
// Calling sc.socket().getRemoteSocketAddress() here throws an exception, so we can only log the error itself
|
||||
log.error("Failed to connect with exception", e);
|
||||
log.error("Failed to connect with exception: {}", e.getMessage());
|
||||
handler.closeConnection();
|
||||
}
|
||||
} else // Process bytes read
|
||||
|
Loading…
Reference in New Issue
Block a user