* I2PTunnel, NTCP: Catch unchecked exceptions from GNU NIO (ticket # 519)

This commit is contained in:
zzz
2011-09-20 04:03:01 +00:00
parent 8a78de2b8c
commit aec3976896
2 changed files with 35 additions and 1 deletions

View File

@@ -194,6 +194,20 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
} catch (IOException ex) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Error forwarding", ex);
} catch (IllegalStateException ise) {
// JamVM (Gentoo: jamvm-1.5.4, gnu-classpath-0.98+gmp)
//java.nio.channels.NotYetConnectedException
// at gnu.java.nio.SocketChannelImpl.write(SocketChannelImpl.java:240)
// at gnu.java.net.PlainSocketImpl$SocketOutputStream.write(PlainSocketImpl.java:668)
// at java.io.OutputStream.write(OutputStream.java:86)
// at net.i2p.i2ptunnel.I2PTunnelHTTPClient.writeFooter(I2PTunnelHTTPClient.java:1029)
// at net.i2p.i2ptunnel.I2PTunnelHTTPClient.writeErrorMessage(I2PTunnelHTTPClient.java:1114)
// at net.i2p.i2ptunnel.I2PTunnelHTTPClient.handleHTTPClientException(I2PTunnelHTTPClient.java:1131)
// at net.i2p.i2ptunnel.I2PTunnelHTTPClient.access$000(I2PTunnelHTTPClient.java:67)
// at net.i2p.i2ptunnel.I2PTunnelHTTPClient$OnTimeout.run(I2PTunnelHTTPClient.java:1052)
// at net.i2p.i2ptunnel.I2PTunnelRunner.run(I2PTunnelRunner.java:167)
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", ise);
} catch (Exception e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Internal error", e);

View File

@@ -213,7 +213,7 @@ class EventPumper implements Runnable {
}
}
} catch (RuntimeException re) {
_log.log(Log.CRIT, "Error in the event pumper", re);
_log.error("Error in the event pumper", re);
}
}
try {
@@ -571,6 +571,22 @@ class EventPumper implements Runnable {
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
} catch (CancelledKeyException cke) {
// ignore, we remove/etc elsewhere
} catch (IllegalArgumentException iae) {
// JamVM (Gentoo: jamvm-1.5.4, gnu-classpath-0.98+gmp)
// throws
//java.lang.IllegalArgumentException: java.io.IOException: Bad file descriptor
// at gnu.java.nio.EpollSelectionKeyImpl.interestOps(EpollSelectionKeyImpl.java:102)
// at net.i2p.router.transport.ntcp.EventPumper.runDelayedEvents(EventPumper.java:580)
// at net.i2p.router.transport.ntcp.EventPumper.run(EventPumper.java:109)
// at java.lang.Thread.run(Thread.java:745)
// at net.i2p.util.I2PThread.run(I2PThread.java:85)
//Caused by: java.io.IOException: Bad file descriptor
// at gnu.java.nio.EpollSelectorImpl.epoll_modify(Native Method)
// at gnu.java.nio.EpollSelectorImpl.epoll_modify(EpollSelectorImpl.java:313)
// at gnu.java.nio.EpollSelectionKeyImpl.interestOps(EpollSelectionKeyImpl.java:97)
// ...4 more
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", iae);
}
}
@@ -580,6 +596,10 @@ class EventPumper implements Runnable {
key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
} catch (CancelledKeyException cke) {
// ignore
} catch (IllegalArgumentException iae) {
// see above
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", iae);
}
}