I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 4e91bb88 authored by jrandom's avatar jrandom Committed by zzz
Browse files

workaround an aggressively up-to-spec kaffe implementation (the spec says...

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)
parent f60a90e2
No related branches found
No related tags found
No related merge requests found
......@@ -250,6 +250,14 @@ class RestrictiveTCPConnection extends TCPConnection {
long start = _context.clock().now();
long success = 0;
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();
try {
_socket.setSoTimeout(ESTABLISHMENT_TIMEOUT);
......@@ -307,17 +315,17 @@ class RestrictiveTCPConnection extends TCPConnection {
} catch (IOException ioe) {
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();
return null;
} catch (DataFormatException dfe) {
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();
return null;
} catch (Throwable t) {
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();
return null;
} finally {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment