From aec397689681150d6b68585b7c48fe11e8076be8 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Tue, 20 Sep 2011 04:03:01 +0000 Subject: [PATCH] * I2PTunnel, NTCP: Catch unchecked exceptions from GNU NIO (ticket # 519) --- .../net/i2p/i2ptunnel/I2PTunnelRunner.java | 14 ++++++++++++ .../router/transport/ntcp/EventPumper.java | 22 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java index 26d3e72d18..33d46238db 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java @@ -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); diff --git a/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java b/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java index c302463c03..ced73d512d 100644 --- a/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java +++ b/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java @@ -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); } } -- GitLab