workaround an aggressively up-to-spec kaffe implementation (the spec says Socket.getInetAddress() is null if not connected,
but sun lets the getInetAddress() return a value if it had connected then disconnected, while kaffe buggers off and NPEs)
This commit is contained in:
@ -250,6 +250,14 @@ class RestrictiveTCPConnection extends TCPConnection {
|
|||||||
long start = _context.clock().now();
|
long start = _context.clock().now();
|
||||||
long success = 0;
|
long success = 0;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Establishing connection...");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Establishing connection...");
|
||||||
|
int port = _socket.getPort();
|
||||||
|
String host = null;
|
||||||
|
// sun keeps the socket's InetAddress around after its been closed, but kaffe (and the rest of classpath)
|
||||||
|
// doesn't, so we've got to check & cache it here if we want to log it later. (kaffe et al are acting per
|
||||||
|
// spec, btw)
|
||||||
|
if (_socket.isConnected())
|
||||||
|
host = _socket.getInetAddress().getHostName();
|
||||||
|
|
||||||
BigInteger myPub = _builder.getMyPublicValue();
|
BigInteger myPub = _builder.getMyPublicValue();
|
||||||
try {
|
try {
|
||||||
_socket.setSoTimeout(ESTABLISHMENT_TIMEOUT);
|
_socket.setSoTimeout(ESTABLISHMENT_TIMEOUT);
|
||||||
@ -307,17 +315,17 @@ class RestrictiveTCPConnection extends TCPConnection {
|
|||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error establishing connection with " + _socket.getInetAddress().getHostAddress() + ":" + _socket.getPort(), ioe);
|
_log.warn("Error establishing connection with " + host + ":" + port, ioe);
|
||||||
closeConnection();
|
closeConnection();
|
||||||
return null;
|
return null;
|
||||||
} catch (DataFormatException dfe) {
|
} catch (DataFormatException dfe) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error establishing connection with " + _socket.getInetAddress().getHostAddress() + ":" + _socket.getPort(), dfe);
|
_log.warn("Error establishing connection with " + host + ":" + port, dfe);
|
||||||
closeConnection();
|
closeConnection();
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
if (_log.shouldLog(Log.ERROR))
|
if (_log.shouldLog(Log.ERROR))
|
||||||
_log.error("jrandom is paranoid so we're catching it all during establishConnection " + _socket.getInetAddress().getHostAddress() + ":" + _socket.getPort(), t);
|
_log.error("jrandom is paranoid so we're catching it all during establishConnection " + host + ":" + port, t);
|
||||||
closeConnection();
|
closeConnection();
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
Reference in New Issue
Block a user