diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
index 5f5bb94d9..f8996d14b 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
@@ -2051,7 +2051,7 @@ public class SnarkManager implements CompleteListener {
synchronized (_snarks) {
ok = monitorTorrents(dir);
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("Error in the DirectoryMonitor", e);
ok = false;
}
@@ -2060,7 +2060,7 @@ public class SnarkManager implements CompleteListener {
try {
addMagnets();
doMagnets = false;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("Error in the DirectoryMonitor", e);
}
if (!_snarks.isEmpty())
@@ -2266,7 +2266,7 @@ public class SnarkManager implements CompleteListener {
// Snark.fatal() throws a RuntimeException
// don't let one bad torrent kill the whole loop
addTorrent(name, null, !shouldAutoStart());
- } catch (Exception e) {
+ } catch (RuntimeException e) {
addMessage(_t("Error: Could not add the torrent {0}", name) + ": " + e);
_log.error("Unable to add the torrent " + name, e);
rv = false;
@@ -2285,7 +2285,7 @@ public class SnarkManager implements CompleteListener {
// Snark.fatal() throws a RuntimeException
// don't let one bad torrent kill the whole loop
stopTorrent(name, true);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// don't bother with message
}
}
@@ -2467,7 +2467,7 @@ public class SnarkManager implements CompleteListener {
public void run() {
try {
run2();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("Error starting", e);
}
}
@@ -2595,7 +2595,7 @@ public class SnarkManager implements CompleteListener {
} else {
addMessageNoEscape(_t("Finished recheck of torrent {0}, unchanged", link));
}
- } catch (Exception e) {
+ } catch (IOException e) {
_log.error("Error rechecking " + snark.getBaseName(), e);
addMessage(_t("Error checking the torrent {0}", snark.getBaseName()) + ": " + e);
}
diff --git a/apps/i2psnark/java/src/org/klomp/snark/Storage.java b/apps/i2psnark/java/src/org/klomp/snark/Storage.java
index 1edf12b5b..f8771ded3 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/Storage.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/Storage.java
@@ -748,7 +748,7 @@ public class Storage implements Closeable
}
rv = repl;
}
- } catch (Exception ex) {
+ } catch (RuntimeException ex) {
ex.printStackTrace();
}
}
@@ -1483,7 +1483,7 @@ public class Storage implements Closeable
break;
} // switch
} // while
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
error = true;
}
diff --git a/apps/i2psnark/java/src/org/klomp/snark/dht/NodeInfo.java b/apps/i2psnark/java/src/org/klomp/snark/dht/NodeInfo.java
index cd2f73da3..708d2d276 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/dht/NodeInfo.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/dht/NodeInfo.java
@@ -225,7 +225,7 @@ class NodeInfo extends SimpleDataStructure {
NodeInfo ni = (NodeInfo) o;
// assume dest matches, ignore it
return this.hash.equals(ni.hash) && nID.equals(ni.nID) && port == ni.port;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
return false;
}
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/GunzipOutputStream.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/GunzipOutputStream.java
index e0798567d..6f5a4c3a7 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/GunzipOutputStream.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/GunzipOutputStream.java
@@ -105,7 +105,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getTotalRead() {
try {
return inf.getBytesRead();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
return 0;
}
}
@@ -116,7 +116,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getTotalExpanded() {
try {
return inf.getBytesWritten();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -128,7 +128,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public long getRemaining() {
try {
return inf.getRemaining();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -140,7 +140,7 @@ class GunzipOutputStream extends InflaterOutputStream {
public boolean getFinished() {
try {
return inf.finished();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return true;
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
index 7c0062075..e8680e3d3 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
@@ -1873,7 +1873,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
try {
result.fromByteArray(content);
return result;
- } catch (Exception ex) {
+ } catch (RuntimeException ex) {
if (log.shouldLog(Log.INFO))
log.info("File is not a binary destination - trying base64");
try {
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java
index 93785e326..4b1284cfe 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java
@@ -3,6 +3,7 @@
*/
package net.i2p.i2ptunnel;
+import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
+import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketAddress;
import net.i2p.data.Destination;
@@ -122,7 +124,17 @@ public class I2PTunnelClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//t.start();
t.run();
- } catch (Exception ex) {
+ } catch (IOException ex) {
+ if (_log.shouldLog(Log.INFO))
+ _log.info("Error connecting", ex);
+ //l.log("Error connecting: " + ex.getMessage());
+ closeSocket(s);
+ if (i2ps != null) {
+ synchronized (sockLock) {
+ mySockets.remove(sockLock);
+ }
+ }
+ } catch (I2PException ex) {
if (_log.shouldLog(Log.INFO))
_log.info("Error connecting", ex);
//l.log("Error connecting: " + ex.getMessage());
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
index dc2c7fa9a..2ae6abba4 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
@@ -742,7 +742,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
public long getTotalRead() {
try {
return def.getTotalIn();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// j2se 1.4.2_08 on linux is sometimes throwing an NPE in the getTotalIn() implementation
return 0;
}
@@ -750,7 +750,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
public long getTotalCompressed() {
try {
return def.getTotalOut();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// j2se 1.4.2_08 on linux is sometimes throwing an NPE in the getTotalOut() implementation
return 0;
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java
index 7f4c2c22a..f53a72cd1 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
+import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketAddress;
import net.i2p.data.DataHelper;
@@ -142,7 +143,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//out.start();
out.run();
- } catch (Exception ex) {
+ } catch (IOException ex) {
// generally NoRouteToHostException
if (_log.shouldLog(Log.WARN))
_log.warn("Error connecting", ex);
@@ -160,6 +161,23 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
mySockets.remove(sockLock);
}
}
+ } catch (I2PException ex) {
+ if (_log.shouldLog(Log.WARN))
+ _log.warn("Error connecting", ex);
+ //l.log("Error connecting: " + ex.getMessage());
+ try {
+ // Send a response so the user doesn't just see a disconnect
+ // and blame his router or the network.
+ String name = addr != null ? addr.getHostName() : "undefined";
+ String msg = ":" + name + " 499 you :" + ex + "\r\n";
+ s.getOutputStream().write(DataHelper.getUTF8(msg));
+ } catch (IOException ioe) {}
+ closeSocket(s);
+ if (i2ps != null) {
+ synchronized (sockLock) {
+ mySockets.remove(sockLock);
+ }
+ }
}
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelOutproxyRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelOutproxyRunner.java
index 2ed668b7a..d8d9369a0 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelOutproxyRunner.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelOutproxyRunner.java
@@ -182,7 +182,7 @@ public class I2PTunnelOutproxyRunner extends I2PAppThread {
} catch (IllegalStateException ise) {
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", ise);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Internal error", e);
} finally {
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java
index 2acd7cfc8..b8bfdaebf 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java
@@ -326,7 +326,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
// at net.i2p.i2ptunnel.I2PTunnelRunner.run(I2PTunnelRunner.java:167)
if (_log.shouldLog(Log.WARN))
_log.warn("gnu?", ise);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Internal error", e);
} finally {
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java
index 76a52c32b..3b9217238 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java
@@ -517,7 +517,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
break;
} catch(SocketTimeoutException ste) {
// ignored, we never set the timeout
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// streaming borkage
if (_log.shouldLog(Log.ERROR))
_log.error("Uncaught exception accepting", e);
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
index d5ca354c5..4a6e85211 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
@@ -230,7 +230,7 @@ public class TunnelController implements Logging {
}
try {
doStartTunnel();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("Error starting the tunnel " + getName(), e);
log("Error starting the tunnel " + getName() + ": " + e.getMessage());
// if we don't acquire() then the release() in stopTunnel() won't work
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java
index f5b434e3b..24ac12e61 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java
@@ -6,6 +6,7 @@ package net.i2p.i2ptunnel.irc;
import java.net.Socket;
import java.io.IOException;
+import net.i2p.I2PException;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.client.streaming.I2PSocketOptions;
@@ -80,7 +81,14 @@ public class I2PTunnelDCCClient extends I2PTunnelClientBase {
// we are called from an unlimited thread pool, so run inline
//t.start();
t.run();
- } catch (Exception ex) {
+ } catch (IOException ex) {
+ _log.error("Could not make DCC connection to " + _dest + ':' + _remotePort, ex);
+ closeSocket(s);
+ if (i2ps != null) {
+ try { i2ps.close(); } catch (IOException ioe) {}
+ }
+ notifyEvent(CONNECT_STOP_EVENT, Integer.valueOf(getLocalPort()));
+ } catch (I2PException ex) {
_log.error("Could not make DCC connection to " + _dest + ':' + _remotePort, ex);
closeSocket(s);
if (i2ps != null) {
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java
index b2b38398e..eb481f6ea 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java
@@ -9,6 +9,7 @@ import java.util.Properties;
import java.util.TreeMap;
import net.i2p.I2PAppContext;
+import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.crypto.SigType;
import net.i2p.data.DataHelper;
@@ -341,7 +342,8 @@ public class GeneralHelper {
rv = pkf.getDestination();
if (rv != null)
return rv;
- } catch (Exception e) {}
+ } catch (I2PException e) {
+ } catch (IOException e) {}
}
}
return null;
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
index fb9b137b2..d960dc93a 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java
@@ -8,8 +8,11 @@ package net.i2p.i2ptunnel.web;
*
*/
+import java.io.IOException;
import java.util.List;
import java.util.Set;
+
+import net.i2p.I2PException;
import net.i2p.crypto.SigType;
import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
@@ -87,7 +90,8 @@ public class EditBean extends IndexBean {
//System.err.println("Signing " + spoof + " with " + Base64.encode(privKey.getData()));
Signature sig = _context.dsa().sign(spoof.getBytes("UTF-8"), privKey);
return Base64.encode(sig.getData());
- } catch (Exception e) {}
+ } catch (I2PException e) {
+ } catch (IOException e) {}
}
return "";
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
index 15eb3f29e..2f2509c08 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java
@@ -9,12 +9,14 @@ package net.i2p.i2ptunnel.web;
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import net.i2p.I2PAppContext;
+import net.i2p.I2PException;
import net.i2p.app.ClientAppManager;
import net.i2p.app.Outproxy;
import net.i2p.data.Certificate;
@@ -266,7 +268,7 @@ public class IndexBean {
if (_action != null) {
try {
buf.append(processAction()).append('\n');
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "Error processing " + _action, e);
buf.append("Error: ").append(e.toString()).append('\n');
}
@@ -972,7 +974,9 @@ public class IndexBean {
PrivateKeyFile pkf = new PrivateKeyFile(keyFile);
try {
pkf.createIfAbsent();
- } catch (Exception e) {
+ } catch (I2PException e) {
+ return "Create private key file failed: " + e;
+ } catch (IOException e) {
return "Create private key file failed: " + e;
}
switch (_certType) {
@@ -1011,7 +1015,9 @@ public class IndexBean {
try {
pkf.write();
newdest = pkf.getDestination();
- } catch (Exception e) {
+ } catch (I2PException e) {
+ return "Modification failed: " + e;
+ } catch (IOException e) {
return "Modification failed: " + e;
}
return "Destination modified - " +
diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java
index 052eef96c..1d3c77a16 100644
--- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java
+++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java
@@ -274,7 +274,7 @@ public class I2PSocketEepGet extends EepGet {
url = args[i];
}
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
usage();
return;
diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java
index 91c18cfe4..4e6d3b51f 100644
--- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java
+++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java
@@ -195,7 +195,9 @@ public class I2PSocketManagerFactory {
ByteArrayOutputStream keyStream = new ByteArrayOutputStream(1024);
try {
client.createDestination(keyStream, getSigType(opts));
- } catch (Exception e) {
+ } catch (I2PException e) {
+ throw new I2PSessionException("Error creating keys", e);
+ } catch (IOException e) {
throw new I2PSessionException("Error creating keys", e);
}
myPrivateKeyStream = new ByteArrayInputStream(keyStream.toByteArray());
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java
index 7870363b5..2218f06a7 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java
@@ -107,7 +107,7 @@ public class CSSHelper extends HelperBase {
if (Integer.parseInt(r) < MIN_REFRESH)
r = "" + MIN_REFRESH;
_context.router().saveConfig(PROP_REFRESH, r);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
}
}
@@ -117,7 +117,7 @@ public class CSSHelper extends HelperBase {
try {
if (Integer.parseInt(r) < MIN_REFRESH)
r = "" + MIN_REFRESH;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
r = "" + MIN_REFRESH;
}
return r;
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java
index 386eb664e..2af0d5df4 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java
@@ -423,7 +423,7 @@ public class PluginStarter implements Runnable {
addPath(f.toURI().toURL());
log.error("INFO: Adding translation plugin to classpath: " + f);
added = true;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
log.error("Plugin " + appName + " bad classpath element: " + f, e);
}
}
@@ -961,7 +961,7 @@ public class PluginStarter implements Runnable {
urls.add(f.toURI().toURL());
if (log.shouldLog(Log.WARN))
log.warn("INFO: Adding plugin to classpath: " + f);
- } catch (Exception e) {
+ } catch (IOException e) {
log.error("Plugin client " + clientName + " bad classpath element: " + f, e);
}
}
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java
index 89310ebda..7473bb79c 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/I2PSocketManagerFull.java
@@ -9,6 +9,7 @@ import java.net.NoRouteToHostException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketTimeoutException;
+import java.security.GeneralSecurityException;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -259,7 +260,13 @@ public class I2PSocketManagerFull implements I2PSocketManager {
Certificate.NULL_CERT.writeBytes(keyStream);
priv.writeBytes(keyStream);
keys[1].writeBytes(keyStream); // signing priv
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
+ throw new I2PSessionException("Error creating keys", e);
+ } catch (I2PException e) {
+ throw new I2PSessionException("Error creating keys", e);
+ } catch (IOException e) {
+ throw new I2PSessionException("Error creating keys", e);
+ } catch (RuntimeException e) {
throw new I2PSessionException("Error creating keys", e);
}
privateKeyStream = new ByteArrayInputStream(keyStream.toByteArray());
diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java
index 360310682..205fcc8a7 100644
--- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java
+++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java
@@ -164,7 +164,7 @@ public class AddressbookBean extends BaseBean
message = generateLoadMessage();
}
- catch (Exception e) {
+ catch (IOException e) {
warn(e);
} finally {
if (fis != null)
@@ -316,7 +316,7 @@ public class AddressbookBean extends BaseBean
try {
save();
message += "
" + _t("Address book saved.");
- } catch (Exception e) {
+ } catch (IOException e) {
warn(e);
message += "
" + _t("ERROR: Could not write addressbook file.");
}
diff --git a/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java b/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java
index 14eaebbd7..0fd326201 100644
--- a/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java
+++ b/apps/susidns/src/java/src/i2p/susi/dns/NamingServiceBean.java
@@ -205,7 +205,7 @@ public class NamingServiceBean extends AddressbookBean
message = generateLoadMessage();
}
- catch (Exception e) {
+ catch (RuntimeException e) {
warn(e);
}
if( message.length() > 0 )
diff --git a/apps/susimail/src/src/i2p/susi/util/Config.java b/apps/susimail/src/src/i2p/susi/util/Config.java
index a84ccede4..26171e87f 100644
--- a/apps/susimail/src/src/i2p/susi/util/Config.java
+++ b/apps/susimail/src/src/i2p/susi/util/Config.java
@@ -98,7 +98,7 @@ public class Config {
try {
iv = Config.class.getResourceAsStream("/susimail.properties");
properties.load(iv);
- } catch (Exception e) {
+ } catch (IOException e) {
Debug.debug(Debug.ERROR, "Could not open WEB-INF/classes/susimail.properties (possibly in jar), reason: " + e);
} finally {
if(iv != null) try { iv.close(); } catch(IOException ioe) {}
@@ -109,7 +109,7 @@ public class Config {
config = new OrderedProperties();
DataHelper.loadProps(config, cfg);
}
- } catch (Exception e) {
+ } catch (IOException e) {
Debug.debug(Debug.ERROR, "Could not open susimail.config, reason: " + e);
}
}
diff --git a/apps/susimail/src/src/i2p/susi/webmail/Mail.java b/apps/susimail/src/src/i2p/susi/webmail/Mail.java
index 88eb0ecdd..e0386b223 100644
--- a/apps/susimail/src/src/i2p/susi/webmail/Mail.java
+++ b/apps/susimail/src/src/i2p/susi/webmail/Mail.java
@@ -127,7 +127,7 @@ class Mail {
part = new MailPart(rb);
} catch (DecodingException de) {
Debug.debug(Debug.ERROR, "Decode error: " + de);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
Debug.debug(Debug.ERROR, "Parse error: " + e);
}
}
diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java
index e70ee3063..bdcab5e89 100644
--- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java
+++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java
@@ -614,7 +614,7 @@ public class WebMail extends HttpServlet
showBody = false;
reason = _t("Charset \\''{0}\\'' not supported.", quoteHTML( mailPart.charset )) + br;
}
- catch (Exception e1) {
+ catch (IOException e1) {
showBody = false;
reason += _t("Part ({0}) not shown, because of {1}", ident, e1.toString()) + br;
}
diff --git a/apps/susimail/src/src/i2p/susi/webmail/encoding/DecodingException.java b/apps/susimail/src/src/i2p/susi/webmail/encoding/DecodingException.java
index d0d89dd00..46277d7e5 100644
--- a/apps/susimail/src/src/i2p/susi/webmail/encoding/DecodingException.java
+++ b/apps/susimail/src/src/i2p/susi/webmail/encoding/DecodingException.java
@@ -23,10 +23,12 @@
*/
package i2p.susi.webmail.encoding;
+import java.io.IOException;
+
/**
* @author susi
*/
-public class DecodingException extends Exception {
+public class DecodingException extends IOException {
private static final long serialVersionUID = 1L;
public DecodingException( String msg ) {
diff --git a/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java b/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java
index 4ed370dd2..e7db3672d 100644
--- a/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java
+++ b/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java
@@ -233,7 +233,9 @@ public class HeaderLine implements Encoding {
length -= distance;
lastCharWasQuoted = true;
continue;
- } catch (Exception e1) {
+ } catch (IOException e1) {
+ Debug.debug(Debug.ERROR, e1.toString());
+ } catch (RuntimeException e1) {
Debug.debug(Debug.ERROR, e1.toString());
}
}
diff --git a/apps/susimail/src/src/i2p/susi/webmail/smtp/SMTPClient.java b/apps/susimail/src/src/i2p/susi/webmail/smtp/SMTPClient.java
index eb58c8ed5..fc4757735 100644
--- a/apps/susimail/src/src/i2p/susi/webmail/smtp/SMTPClient.java
+++ b/apps/susimail/src/src/i2p/susi/webmail/smtp/SMTPClient.java
@@ -210,7 +210,7 @@ public class SMTPClient {
try {
socket = new Socket( host, port );
- } catch (Exception e) {
+ } catch (IOException e) {
error += _t("Cannot connect") + ": " + e.getMessage() + '\n';
ok = false;
}
diff --git a/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java b/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java
index 642bea630..0389c8dd7 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java
@@ -62,7 +62,7 @@ public class ConfigFile {
try {
fileInputStream = new FileInputStream(_configFile);
_properties.load(fileInputStream);
- } catch (Exception e) {
+ } catch (IOException e) {
rv = false;
} finally {
if (fileInputStream != null) {
@@ -79,7 +79,7 @@ public class ConfigFile {
try {
fileOutputStream = new FileOutputStream(_configFile);
_properties.store(fileOutputStream, null);
- } catch (Exception e) {
+ } catch (IOException e) {
rv = false;
} finally {
if (fileOutputStream != null) {
diff --git a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
index 8d030d091..701c28b87 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
@@ -88,14 +88,14 @@ public class SysTray implements SysTrayMenuListener {
try {
if (urlLauncher.openUrl(url))
return;
- } catch (Exception ex) {
+ } catch (RuntimeException ex) {
// Fall through.
}
} else {
try {
if (urlLauncher.openUrl(url, _browserString))
return;
- } catch (Exception ex) {
+ } catch (RuntimeException ex) {
// Fall through.
}
}
diff --git a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java
index 7169bc8f3..aa8f5ef12 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java
@@ -149,7 +149,7 @@ public class UrlLauncher implements ClientApp {
Thread.sleep(2*1000);
} catch (InterruptedException ie) {}
return true;
- } catch (Exception e) {}
+ } catch (IOException e) {}
if (System.currentTimeMillis() > done)
break;
try {
@@ -171,9 +171,9 @@ public class UrlLauncher implements ClientApp {
* @return true
if the operation was successful, otherwise
* false
.
*
- * @throws Exception
+ * @throws IOException
*/
- public boolean openUrl(String url) throws Exception {
+ public boolean openUrl(String url) throws IOException {
waitForServer(url);
if (validateUrlFormat(url)) {
String cbrowser = _context.getProperty(PROP_BROWSER);
@@ -217,7 +217,7 @@ public class UrlLauncher implements ClientApp {
// No worries.
}
foo.delete();
- } catch (Exception e) {
+ } catch (IOException e) {
// Defaults to IE.
} finally {
if (bufferedReader != null)
@@ -246,9 +246,9 @@ public class UrlLauncher implements ClientApp {
* @return true
if the operation was successful,
* otherwise false
.
*
- * @throws Exception
+ * @throws IOException
*/
- public boolean openUrl(String url, String browser) throws Exception {
+ public boolean openUrl(String url, String browser) throws IOException {
waitForServer(url);
if (validateUrlFormat(url)) {
if (_shellCommand.executeSilentAndWaitTimed(browser + " " + url, 5))
@@ -289,7 +289,7 @@ public class UrlLauncher implements ClientApp {
String url = _args[0];
openUrl(url);
changeState(STOPPED);
- } catch (Exception e) {
+ } catch (IOException e) {
changeState(CRASHED, e);
}
}
@@ -354,6 +354,6 @@ public class UrlLauncher implements ClientApp {
launcher.openUrl(args[0]);
else
launcher.openUrl("http://127.0.0.1:7657/index.jsp");
- } catch (Exception e) {}
+ } catch (IOException e) {}
}
}
diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
index 046683ea4..13d805619 100644
--- a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
+++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
@@ -862,7 +862,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
if ((duration > 100) && _log.shouldLog(Log.INFO))
_log.info("Message availability notification for " + msgId.intValue() + " took "
+ duration + " to " + _sessionListener);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "Error notifying app of message availability", e);
}
} else {
diff --git a/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java
index 07003ae2d..9b6f1ff0c 100644
--- a/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java
+++ b/core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java
@@ -399,7 +399,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 {
try {
_demultiplexer.messageAvailable(I2PSessionMuxedImpl.this,
msg.id, msg.size, msg.proto, msg.fromPort, msg.toPort);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("Error notifying app of message availability", e);
}
}
diff --git a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java
index 219c61bbc..38a174b7e 100644
--- a/core/java/src/net/i2p/client/naming/SingleFileNamingService.java
+++ b/core/java/src/net/i2p/client/naming/SingleFileNamingService.java
@@ -91,7 +91,7 @@ public class SingleFileNamingService extends NamingService {
key = getKey(hostname.substring(4));
if (key != null)
return lookupBase64(key);
- } catch (Exception ioe) {
+ } catch (IOException ioe) {
if (_file.exists())
_log.error("Error loading hosts file " + _file, ioe);
else if (_log.shouldLog(Log.WARN))
@@ -123,7 +123,7 @@ public class SingleFileNamingService extends NamingService {
return line.substring(0, split);
}
return null;
- } catch (Exception ioe) {
+ } catch (IOException ioe) {
if (_file.exists())
_log.error("Error loading hosts file " + _file, ioe);
else if (_log.shouldLog(Log.WARN))
diff --git a/core/java/src/net/i2p/crypto/DSAEngine.java b/core/java/src/net/i2p/crypto/DSAEngine.java
index d7dfe657a..76f2004f8 100644
--- a/core/java/src/net/i2p/crypto/DSAEngine.java
+++ b/core/java/src/net/i2p/crypto/DSAEngine.java
@@ -257,7 +257,7 @@ public class DSAEngine {
_log.warn("Took too long to verify the signature (" + diff + "ms)");
}
return ok;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "Error verifying the signature", e);
return false;
}
diff --git a/core/java/src/net/i2p/crypto/ECConstants.java b/core/java/src/net/i2p/crypto/ECConstants.java
index d9b111e23..8bca0b0ac 100644
--- a/core/java/src/net/i2p/crypto/ECConstants.java
+++ b/core/java/src/net/i2p/crypto/ECConstants.java
@@ -3,6 +3,7 @@ package net.i2p.crypto;
import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.AlgorithmParameters;
+import java.security.GeneralSecurityException;
import java.security.Provider;
import java.security.Security;
import java.security.spec.ECField;
@@ -278,7 +279,7 @@ class ECConstants {
AlgorithmParameters ap;
try {
ap = AlgorithmParameters.getInstance("EC");
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
if (BC_AVAILABLE) {
log("Named curve " + name + " is not available, trying BC", e);
ap = AlgorithmParameters.getInstance("EC", "BC");
@@ -292,7 +293,7 @@ class ECConstants {
ECParameterSpec rv = ap.getParameterSpec(ECParameterSpec.class);
log("Named curve " + name + " loaded");
return rv;
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
log("Named curve " + name + " is not available", e);
return null;
}
diff --git a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java
index 126a06a36..0fe652bb2 100644
--- a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java
+++ b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java
@@ -327,12 +327,12 @@ public class ElGamalAESEngine {
//ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
int cur = 0;
long numTags = DataHelper.fromLong(decrypted, cur, 2);
- if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new Exception("Invalid number of session tags");
+ if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new IllegalArgumentException("Invalid number of session tags");
if (numTags > 0) tags = new ArrayList((int)numTags);
cur += 2;
//_log.debug("# tags: " + numTags);
if (numTags * SessionTag.BYTE_LENGTH > decrypted.length - 2) {
- throw new Exception("# tags: " + numTags + " is too many for " + (decrypted.length - 2));
+ throw new IllegalArgumentException("# tags: " + numTags + " is too many for " + (decrypted.length - 2));
}
for (int i = 0; i < numTags; i++) {
byte tag[] = new byte[SessionTag.BYTE_LENGTH];
@@ -344,7 +344,7 @@ public class ElGamalAESEngine {
cur += 4;
//_log.debug("len: " + len);
if ((len < 0) || (len > decrypted.length - cur - Hash.HASH_LENGTH - 1))
- throw new Exception("Invalid size of payload (" + len + ", remaining " + (decrypted.length-cur) +")");
+ throw new IllegalArgumentException("Invalid size of payload (" + len + ", remaining " + (decrypted.length-cur) +")");
//byte hashval[] = new byte[Hash.HASH_LENGTH];
//System.arraycopy(decrypted, cur, hashval, 0, Hash.HASH_LENGTH);
//readHash = new Hash();
@@ -379,8 +379,8 @@ public class ElGamalAESEngine {
return unencrData;
}
- throw new Exception("Hash does not match");
- } catch (Exception e) {
+ throw new RuntimeException("Hash does not match");
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.WARN)) _log.warn("Unable to decrypt AES block", e);
return null;
}
diff --git a/core/java/src/net/i2p/crypto/EncType.java b/core/java/src/net/i2p/crypto/EncType.java
index cb9c0ad96..fc07d5d5a 100644
--- a/core/java/src/net/i2p/crypto/EncType.java
+++ b/core/java/src/net/i2p/crypto/EncType.java
@@ -108,7 +108,7 @@ public enum EncType {
return true;
try {
getParams();
- } catch (Exception e) {
+ } catch (InvalidParameterSpecException e) {
return false;
}
return true;
diff --git a/core/java/src/net/i2p/crypto/KeyGenerator.java b/core/java/src/net/i2p/crypto/KeyGenerator.java
index 60742c2fb..c198d0b34 100644
--- a/core/java/src/net/i2p/crypto/KeyGenerator.java
+++ b/core/java/src/net/i2p/crypto/KeyGenerator.java
@@ -343,7 +343,7 @@ public class KeyGenerator {
public static void main(String args[]) {
try {
main2(args);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
}
}
@@ -381,7 +381,7 @@ public class KeyGenerator {
try {
System.out.println("Testing " + type);
testSig(type, runs);
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
System.out.println("error testing " + type);
e.printStackTrace();
}
diff --git a/core/java/src/net/i2p/crypto/KeyStoreUtil.java b/core/java/src/net/i2p/crypto/KeyStoreUtil.java
index 06b73cea8..d994018cf 100644
--- a/core/java/src/net/i2p/crypto/KeyStoreUtil.java
+++ b/core/java/src/net/i2p/crypto/KeyStoreUtil.java
@@ -98,7 +98,8 @@ public class KeyStoreUtil {
try {
ks.load(null, DEFAULT_KEYSTORE_PASSWORD.toCharArray());
success = addCerts(new File(System.getProperty("java.home"), "etc/security/cacerts"), ks) > 0;
- } catch (Exception e) {}
+ } catch (IOException e) {
+ } catch (GeneralSecurityException e) {}
} else {
success = loadCerts(new File(System.getProperty("java.home"), "etc/security/cacerts.bks"), ks);
}
@@ -113,7 +114,8 @@ public class KeyStoreUtil {
try {
// must be initted
ks.load(null, DEFAULT_KEYSTORE_PASSWORD.toCharArray());
- } catch (Exception e) {}
+ } catch (IOException e) {
+ } catch (GeneralSecurityException e) {}
error("All key store loads failed, will only load local certificates", null);
}
return ks;
@@ -140,13 +142,15 @@ public class KeyStoreUtil {
try {
// not clear if null is allowed for password
ks.load(null, DEFAULT_KEYSTORE_PASSWORD.toCharArray());
- } catch (Exception foo) {}
+ } catch (IOException foo) {
+ } catch (GeneralSecurityException e) {}
return false;
} catch (IOException ioe) {
error("KeyStore load error, no default keys: " + file.getAbsolutePath(), ioe);
try {
ks.load(null, DEFAULT_KEYSTORE_PASSWORD.toCharArray());
- } catch (Exception foo) {}
+ } catch (IOException foo) {
+ } catch (GeneralSecurityException e) {}
return false;
} finally {
try { if (fis != null) fis.close(); } catch (IOException foo) {}
@@ -171,7 +175,7 @@ public class KeyStoreUtil {
count++;
}
}
- } catch (Exception foo) {}
+ } catch (GeneralSecurityException e) {}
return count;
}
@@ -316,7 +320,10 @@ public class KeyStoreUtil {
error("Not overwriting key " + alias + ", already exists in " + ks, null);
return false;
}
- } catch (Exception e) {
+ } catch (IOException e) {
+ error("Not overwriting key \"" + alias + "\", already exists in " + ks, e);
+ return false;
+ } catch (GeneralSecurityException e) {
error("Not overwriting key \"" + alias + "\", already exists in " + ks, e);
return false;
}
@@ -354,7 +361,10 @@ public class KeyStoreUtil {
success = getPrivateKey(ks, ksPW, alias, keyPW) != null;
if (!success)
error("Key gen failed to get private key", null);
- } catch (Exception e) {
+ } catch (IOException e) {
+ error("Key gen failed to get private key", e);
+ success = false;
+ } catch (GeneralSecurityException e) {
error("Key gen failed to get private key", e);
success = false;
}
diff --git a/core/java/src/net/i2p/crypto/SigType.java b/core/java/src/net/i2p/crypto/SigType.java
index 48ad93e0a..05dd1906e 100644
--- a/core/java/src/net/i2p/crypto/SigType.java
+++ b/core/java/src/net/i2p/crypto/SigType.java
@@ -1,5 +1,6 @@
package net.i2p.crypto;
+import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
@@ -215,7 +216,9 @@ public enum SigType {
}
getDigestInstance();
getHashInstance();
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
+ return false;
+ } catch (RuntimeException e) {
return false;
}
return true;
diff --git a/core/java/src/net/i2p/crypto/TrustedUpdate.java b/core/java/src/net/i2p/crypto/TrustedUpdate.java
index b365a662a..5174292a2 100644
--- a/core/java/src/net/i2p/crypto/TrustedUpdate.java
+++ b/core/java/src/net/i2p/crypto/TrustedUpdate.java
@@ -344,7 +344,11 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
System.out.println("\r\nPrivate key written to: " + privateKeyFile);
System.out.println("Public key written to: " + publicKeyFile);
System.out.println("\r\nPublic key: " + signingPublicKey.toBase64() + "\r\n");
- } catch (Exception e) {
+ } catch (IOException e) {
+ System.err.println("Error writing keys:");
+ e.printStackTrace();
+ return false;
+ } catch (DataFormatException e) {
System.err.println("Error writing keys:");
e.printStackTrace();
return false;
@@ -758,7 +762,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
bytesToSignInputStream = new SequenceInputStream(versionHeaderInputStream, fileInputStream);
signature = _context.dsa().sign(bytesToSignInputStream, signingPrivateKey);
- } catch (Exception e) {
+ } catch (IOException e) {
if (_log.shouldLog(Log.ERROR))
_log.error("Error signing", e);
diff --git a/core/java/src/net/i2p/crypto/eddsa/math/GroupElement.java b/core/java/src/net/i2p/crypto/eddsa/math/GroupElement.java
index 268005ed7..ec81b5d40 100644
--- a/core/java/src/net/i2p/crypto/eddsa/math/GroupElement.java
+++ b/core/java/src/net/i2p/crypto/eddsa/math/GroupElement.java
@@ -722,7 +722,7 @@ public class GroupElement implements Serializable {
if (!this.repr.equals(ge.repr)) {
try {
ge = ge.toRep(this.repr);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
return false;
}
}
diff --git a/core/java/src/net/i2p/data/PrivateKeyFile.java b/core/java/src/net/i2p/data/PrivateKeyFile.java
index f42d8da15..b77fd1350 100644
--- a/core/java/src/net/i2p/data/PrivateKeyFile.java
+++ b/core/java/src/net/i2p/data/PrivateKeyFile.java
@@ -9,6 +9,7 @@ import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@@ -174,7 +175,10 @@ public class PrivateKeyFile {
pkf.write();
verifySignature(pkf.getDestination());
}
- } catch (Exception e) {
+ } catch (I2PException e) {
+ e.printStackTrace();
+ System.exit(1);
+ } catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
@@ -358,7 +362,7 @@ public class PrivateKeyFile {
HashCash hc;
try {
hc = HashCash.mintCash(resource, effort);
- } catch (Exception e) {
+ } catch (NoSuchAlgorithmException e) {
return null;
}
System.out.println("Generation took: " + DataHelper.formatDuration(System.currentTimeMillis() - begin));
@@ -391,7 +395,9 @@ public class PrivateKeyFile {
Destination d2;
try {
d2 = pkf2.getDestination();
- } catch (Exception e) {
+ } catch (I2PException e) {
+ return null;
+ } catch (IOException e) {
return null;
}
if (d2 == null)
@@ -500,7 +506,7 @@ public class PrivateKeyFile {
long low = Long.MAX_VALUE;
try {
low = HashCash.estimateTime(hashEffort);
- } catch (Exception e) {}
+ } catch (NoSuchAlgorithmException e) {}
// takes a lot longer than the estimate usually...
// maybe because the resource string is much longer than used in the estimate?
return "It is estimated that generating a HashCash Certificate with value " + hashEffort +
diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java
index 4dfbb8501..4bfdbc158 100644
--- a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java
+++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java
@@ -160,7 +160,7 @@ public class I2CPMessageReader {
public void run() {
try {
run2();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "Uncaught I2CP error", e);
_listener.readError(I2CPMessageReader.this, e);
cancelRunner();
@@ -193,7 +193,7 @@ public class I2CPMessageReader {
} catch (OutOfMemoryError oom) {
// ooms seen here... maybe log and keep going?
throw oom;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "Unhandled error reading I2CP stream", e);
_listener.disconnected(I2CPMessageReader.this);
cancelRunner();
diff --git a/core/java/src/net/i2p/stat/BufferedStatLog.java b/core/java/src/net/i2p/stat/BufferedStatLog.java
index 7c9b7b723..5734e8948 100644
--- a/core/java/src/net/i2p/stat/BufferedStatLog.java
+++ b/core/java/src/net/i2p/stat/BufferedStatLog.java
@@ -145,7 +145,7 @@ public class BufferedStatLog implements StatLog {
if (_log.shouldLog(Log.DEBUG))
_log.debug("writing " + writeStart +"->"+ writeEnd);
writeEvents(writeStart, writeEnd);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("error writing " + writeStart +"->"+ writeEnd, e);
}
}
diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java
index 81ec7c8e4..d9d9ba6fe 100644
--- a/core/java/src/net/i2p/util/EepGet.java
+++ b/core/java/src/net/i2p/util/EepGet.java
@@ -273,7 +273,7 @@ public class EepGet {
break;
} // switch
} // while
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
error = true;
}
diff --git a/core/java/src/net/i2p/util/EepHead.java b/core/java/src/net/i2p/util/EepHead.java
index 2c49d708b..ef6f5067d 100644
--- a/core/java/src/net/i2p/util/EepHead.java
+++ b/core/java/src/net/i2p/util/EepHead.java
@@ -109,7 +109,7 @@ public class EepHead extends EepGet {
break;
} // switch
} // while
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
error = true;
}
diff --git a/core/java/src/net/i2p/util/FortunaRandomSource.java b/core/java/src/net/i2p/util/FortunaRandomSource.java
index 9688e8764..e386e325c 100644
--- a/core/java/src/net/i2p/util/FortunaRandomSource.java
+++ b/core/java/src/net/i2p/util/FortunaRandomSource.java
@@ -11,6 +11,7 @@ package net.i2p.util;
import gnu.crypto.prng.AsyncFortunaStandalone;
+import java.io.IOException;
import java.security.SecureRandom;
import net.i2p.I2PAppContext;
@@ -266,7 +267,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
synchronized(_fortuna) {
_fortuna.addRandomBytes(data, offset, len);
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// AIOOBE seen, root cause unknown, ticket #1576
Log log = _context.logManager().getLog(FortunaRandomSource.class);
log.warn("feedEntropy()", e);
@@ -290,6 +291,6 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
rand.nextBytes(buf);
System.out.write(buf);
}
- } catch (Exception e) { e.printStackTrace(); }
+ } catch (IOException e) { e.printStackTrace(); }
}
}
diff --git a/core/java/src/net/i2p/util/LogWriterBase.java b/core/java/src/net/i2p/util/LogWriterBase.java
index b9b98e10d..cc4fb93e6 100644
--- a/core/java/src/net/i2p/util/LogWriterBase.java
+++ b/core/java/src/net/i2p/util/LogWriterBase.java
@@ -75,7 +75,7 @@ abstract class LogWriterBase implements Runnable {
if (_write && shouldReadConfig)
rereadConfig();
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
System.err.println("Error writing the log: " + e);
e.printStackTrace();
}
diff --git a/core/java/src/net/i2p/util/PartialEepGet.java b/core/java/src/net/i2p/util/PartialEepGet.java
index 0371dbf32..4d0967763 100644
--- a/core/java/src/net/i2p/util/PartialEepGet.java
+++ b/core/java/src/net/i2p/util/PartialEepGet.java
@@ -107,7 +107,7 @@ public class PartialEepGet extends EepGet {
break;
} // switch
} // while
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
error = true;
}
diff --git a/core/java/src/net/i2p/util/ResettableGZIPInputStream.java b/core/java/src/net/i2p/util/ResettableGZIPInputStream.java
index 645bd29f3..13eecb518 100644
--- a/core/java/src/net/i2p/util/ResettableGZIPInputStream.java
+++ b/core/java/src/net/i2p/util/ResettableGZIPInputStream.java
@@ -124,7 +124,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
public long getTotalRead() {
try {
return inf.getBytesRead();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
return 0;
}
}
@@ -136,7 +136,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
public long getTotalExpanded() {
try {
return inf.getBytesWritten();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -149,7 +149,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
public long getRemaining() {
try {
return inf.getRemaining();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return 0;
}
@@ -162,7 +162,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
public boolean getFinished() {
try {
return inf.finished();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// possible NPE in some implementations
return true;
}
diff --git a/core/java/src/net/i2p/util/SSLEepGet.java b/core/java/src/net/i2p/util/SSLEepGet.java
index 4cc31e90b..c62da0c12 100644
--- a/core/java/src/net/i2p/util/SSLEepGet.java
+++ b/core/java/src/net/i2p/util/SSLEepGet.java
@@ -180,7 +180,7 @@ public class SSLEepGet extends EepGet {
break;
} // switch
} // while
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
error = true;
}
@@ -370,7 +370,7 @@ public class SSLEepGet extends EepGet {
System.out.println(" Valid To: " + cert.getNotAfter());
try {
cert.checkValidity();
- } catch (Exception e) {
+ } catch (GeneralSecurityException e) {
System.out.println(" WARNING: Certificate is not currently valid, it cannot be used");
}
CertUtil.saveCert(cert, new File(name));
diff --git a/core/java/src/net/i2p/util/ShellCommand.java b/core/java/src/net/i2p/util/ShellCommand.java
index 955830fe1..4a5daac55 100644
--- a/core/java/src/net/i2p/util/ShellCommand.java
+++ b/core/java/src/net/i2p/util/ShellCommand.java
@@ -439,7 +439,7 @@ public class ShellCommand {
System.out.println("ShellCommand waiting for \"" + name + '\"');
try {
process.waitFor();
- } catch (Exception e) {
+ } catch (InterruptedException e) {
if (DEBUG) {
System.out.println("ShellCommand exception waiting for \"" + name + '\"');
e.printStackTrace();
@@ -457,7 +457,7 @@ public class ShellCommand {
if (process.exitValue() > 0)
return false;
}
- } catch (Exception e) {
+ } catch (IOException e) {
// probably IOException, file not found from exec()
if (DEBUG) {
System.out.println("ShellCommand execute exception for \"" + name + '\"');
diff --git a/core/java/src/net/metanotion/io/block/BlockFile.java b/core/java/src/net/metanotion/io/block/BlockFile.java
index 018702204..122f30796 100644
--- a/core/java/src/net/metanotion/io/block/BlockFile.java
+++ b/core/java/src/net/metanotion/io/block/BlockFile.java
@@ -147,7 +147,7 @@ public class BlockFile implements Closeable {
bf.bfck(true);
bf.close();
raif.close();
- } catch (Exception e) {
+ } catch (IOException e) {
e.printStackTrace();
}
}
diff --git a/installer/java/src/net/i2p/installer/Exec.java b/installer/java/src/net/i2p/installer/Exec.java
index b8488ceff..05113b9c6 100644
--- a/installer/java/src/net/i2p/installer/Exec.java
+++ b/installer/java/src/net/i2p/installer/Exec.java
@@ -21,7 +21,7 @@ public class Exec {
try { proc.exitValue(); } catch (Throwable t) { }
Runtime.getRuntime().halt(0);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
}
}
diff --git a/installer/tools/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java b/installer/tools/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java
index f916e976f..ac405f0ee 100644
--- a/installer/tools/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java
+++ b/installer/tools/java/src/net/i2p/router/networkdb/kademlia/BundleRouterInfos.java
@@ -109,7 +109,7 @@ public class BundleRouterInfos {
RouterInfo ri = new RouterInfo();
ri.readBytes(fis, true); // true = verify sig on read
me = ri.getIdentity().getHash();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
//System.out.println("Can't determine our identity");
} finally {
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
@@ -209,7 +209,7 @@ public class BundleRouterInfos {
copied++;
else
System.out.println("Failed copy of " + file + " to " + toDir);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
System.out.println("Skipping bad " + file);
} finally {
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
diff --git a/router/java/src/net/i2p/data/i2np/GarlicClove.java b/router/java/src/net/i2p/data/i2np/GarlicClove.java
index 628874d81..d19435321 100644
--- a/router/java/src/net/i2p/data/i2np/GarlicClove.java
+++ b/router/java/src/net/i2p/data/i2np/GarlicClove.java
@@ -158,7 +158,7 @@ public class GarlicClove extends DataStructureImpl {
if (m.length <= 0)
throw new RuntimeException("foo, returned 0 length");
out.write(m);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
throw new DataFormatException("Unable to write the clove: " + _msg + " to " + out, e);
}
DataHelper.writeLong(out, 4, _cloveId);
@@ -187,7 +187,7 @@ public class GarlicClove extends DataStructureImpl {
byte m[] = _msg.toByteArray();
System.arraycopy(m, 0, rv, offset, m.length);
offset += m.length;
- } catch (Exception e) { throw new RuntimeException("Unable to write: " + _msg + ": " + e.getMessage()); }
+ } catch (RuntimeException e) { throw new RuntimeException("Unable to write: " + _msg + ": " + e.getMessage()); }
DataHelper.toLong(rv, offset, 4, _cloveId);
offset += 4;
DataHelper.toDate(rv, offset, _expiration.getTime());
diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java b/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java
index f1ea685f9..224918ef4 100644
--- a/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java
+++ b/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java
@@ -59,7 +59,7 @@ public class I2NPMessageHandler {
_lastSize = msg.readBytes(in, type, _messageBuffer);
} catch (I2NPMessageException ime) {
throw ime;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error reading the stream", e);
throw new I2NPMessageException("Unknown error reading the " + msg.getClass().getSimpleName(), e);
@@ -131,7 +131,7 @@ public class I2NPMessageHandler {
cur += _lastSize;
} catch (I2NPMessageException ime) {
throw ime;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error reading the stream", e);
throw new I2NPMessageException("Unknown error reading the " + msg.getClass().getSimpleName(), e);
diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageReader.java b/router/java/src/net/i2p/data/i2np/I2NPMessageReader.java
index f253cfed2..d23a489d6 100644
--- a/router/java/src/net/i2p/data/i2np/I2NPMessageReader.java
+++ b/router/java/src/net/i2p/data/i2np/I2NPMessageReader.java
@@ -163,7 +163,7 @@ public class I2NPMessageReader {
_log.warn("IO Error handling message", ioe);
_listener.disconnected(I2NPMessageReader.this);
cancelRunner();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "error reading msg!", e);
_listener.readError(I2NPMessageReader.this, e);
_listener.disconnected(I2NPMessageReader.this);
diff --git a/router/java/src/net/i2p/data/router/RouterInfo.java b/router/java/src/net/i2p/data/router/RouterInfo.java
index 0d60c6dc0..f2f9cdb7f 100644
--- a/router/java/src/net/i2p/data/router/RouterInfo.java
+++ b/router/java/src/net/i2p/data/router/RouterInfo.java
@@ -724,7 +724,10 @@ public class RouterInfo extends DatabaseEntry {
System.err.println("Router info " + args[i] + " is invalid");
fail = true;
}
- } catch (Exception e) {
+ } catch (IOException e) {
+ System.err.println("Error reading " + args[i] + ": " + e);
+ fail = true;
+ } catch (DataFormatException e) {
System.err.println("Error reading " + args[i] + ": " + e);
fail = true;
} finally {
diff --git a/router/java/src/net/i2p/router/InNetMessagePool.java b/router/java/src/net/i2p/router/InNetMessagePool.java
index fb4c2a632..bfd3d696e 100644
--- a/router/java/src/net/i2p/router/InNetMessagePool.java
+++ b/router/java/src/net/i2p/router/InNetMessagePool.java
@@ -434,7 +434,7 @@ public class InNetMessagePool implements Service {
} catch (OutOfMemoryError oome) {
throw oome;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.CRIT))
_log.log(Log.CRIT, "Error in the tunnel gateway dispatcher", e);
}
@@ -467,7 +467,7 @@ public class InNetMessagePool implements Service {
} catch (OutOfMemoryError oome) {
throw oome;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.CRIT))
_log.log(Log.CRIT, "Error in the tunnel data dispatcher", e);
}
diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java
index 426da4a75..99073c366 100644
--- a/router/java/src/net/i2p/router/Router.java
+++ b/router/java/src/net/i2p/router/Router.java
@@ -9,6 +9,7 @@ package net.i2p.router;
*/
import java.io.File;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -648,7 +649,7 @@ public class Router implements RouterClock.ClockShiftListener {
//else
// System.err.println("WARNING: Configuration file " + filename + " does not exist");
}
- } catch (Exception ioe) {
+ } catch (IOException ioe) {
if (log != null)
log.error("Error loading the router configuration from " + filename, ioe);
else
@@ -1351,7 +1352,7 @@ public class Router implements RouterClock.ClockShiftListener {
ordered.putAll(_config);
DataHelper.storeProps(ordered, new File(_configFilename));
}
- } catch (Exception ioe) {
+ } catch (IOException ioe) {
// warning, _log will be null when called from constructor
if (_log != null)
_log.error("Error saving the config to " + _configFilename, ioe);
diff --git a/router/java/src/net/i2p/router/dummy/VMCommSystem.java b/router/java/src/net/i2p/router/dummy/VMCommSystem.java
index 13b8aff0a..29f232370 100644
--- a/router/java/src/net/i2p/router/dummy/VMCommSystem.java
+++ b/router/java/src/net/i2p/router/dummy/VMCommSystem.java
@@ -8,6 +8,7 @@ import java.util.Map;
import net.i2p.data.Hash;
import net.i2p.data.i2np.I2NPMessage;
+import net.i2p.data.i2np.I2NPMessageException;
import net.i2p.data.i2np.I2NPMessageHandler;
import net.i2p.router.CommSystemFacade;
import net.i2p.router.JobImpl;
@@ -121,7 +122,7 @@ public class VMCommSystem extends CommSystemFacade {
ReceiveJob.this.getContext().statManager().addRateData("transport.receiveMessageLarge", 1, 1);
_ctx.inNetMessagePool().add(msg, null, _from);
- } catch (Exception e) {
+ } catch (I2NPMessageException e) {
_log.error("Error reading/formatting a VM message? Something is not right...", e);
}
}
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java
index a04a339cc..f915b03f7 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java
@@ -543,7 +543,7 @@ public class PersistentDataStore extends TransientDataStore {
if (_log.shouldLog(Log.INFO))
_log.info("Unable to read the router reference in " + _routerFile.getName(), ioe);
corrupt = true;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// key certificate problems, etc., don't let one bad RI kill the whole thing
if (_log.shouldLog(Log.INFO))
_log.info("Unable to read the router reference in " + _routerFile.getName(), e);
@@ -666,7 +666,7 @@ public class PersistentDataStore extends TransientDataStore {
return null;
Hash h = Hash.create(b);
return h;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// static
//_log.warn("Unable to fetch the key from [" + filename + "]", e);
return null;
diff --git a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java
index dfe72e155..1060d444f 100644
--- a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java
+++ b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java
@@ -626,7 +626,7 @@ public class Reseeder {
if (fetched % 60 == 0)
System.out.println();
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
if (_log.shouldLog(Log.INFO))
_log.info("Failed fetch", e);
errors++;
diff --git a/router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java b/router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java
index 305d0f343..af9cd33aa 100644
--- a/router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java
+++ b/router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java
@@ -301,7 +301,7 @@ class ProfilePersistenceHelper {
_log.debug("Loaded the profile for " + peer.toBase64() + " from " + file.getName());
return profile;
- } catch (Exception e) {
+ } catch (IOException e) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error loading properties from " + file.getAbsolutePath(), e);
file.delete();
@@ -369,7 +369,7 @@ class ProfilePersistenceHelper {
return null;
Hash h = Hash.create(b);
return h;
- } catch (Exception dfe) {
+ } catch (RuntimeException dfe) {
_log.warn("Invalid base64 [" + key + "]", dfe);
return null;
}
diff --git a/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java b/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java
index ef0826cf5..a3302ae40 100644
--- a/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java
+++ b/router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java
@@ -98,7 +98,13 @@ class RebuildRouterInfoJob extends JobImpl {
KeyData kd = LoadRouterInfoJob.readKeyData(keyFile, keyFile2);
info = new RouterInfo();
info.setIdentity(kd.routerIdentity);
- } catch (Exception e) {
+ } catch (DataFormatException e) {
+ _log.log(Log.CRIT, "Error reading in the key data from " + keyFile.getAbsolutePath(), e);
+ keyFile.delete();
+ keyFile2.delete();
+ rebuildRouterInfo(alreadyRunning);
+ return;
+ } catch (IOException e) {
_log.log(Log.CRIT, "Error reading in the key data from " + keyFile.getAbsolutePath(), e);
keyFile.delete();
keyFile2.delete();
diff --git a/router/java/src/net/i2p/router/transport/UPnP.java b/router/java/src/net/i2p/router/transport/UPnP.java
index 8aab1d1d4..58cc32c75 100644
--- a/router/java/src/net/i2p/router/transport/UPnP.java
+++ b/router/java/src/net/i2p/router/transport/UPnP.java
@@ -476,7 +476,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
ServiceStateTable table;
try {
table = serv.getServiceStateTable();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// getSCPDNode() returns null,
// NPE at org.cybergarage.upnp.Service.getServiceStateTable(Service.java:526)
sb.append(" : no state");
diff --git a/router/java/src/net/i2p/router/transport/UPnPManager.java b/router/java/src/net/i2p/router/transport/UPnPManager.java
index 9d7a6918a..cd9963b06 100644
--- a/router/java/src/net/i2p/router/transport/UPnPManager.java
+++ b/router/java/src/net/i2p/router/transport/UPnPManager.java
@@ -88,7 +88,7 @@ class UPnPManager {
_isRunning = _upnp.runPlugin();
if (_log.shouldLog(Log.INFO))
_log.info("UPnP runPlugin took " + (_context.clock().now() - b));
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// NPE in UPnP (ticket #728), can't let it bring us down
if (!_errorLogged) {
_log.error("UPnP error, please report", 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 053d4a373..dcc2226c4 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/EventPumper.java
@@ -335,7 +335,7 @@ class EventPumper implements Runnable {
con.close();
key.cancel();
}
- } catch (Exception ke) {
+ } catch (IOException ke) {
_log.error("Error closing key " + key + " on pumper shutdown", ke);
}
}
@@ -344,7 +344,7 @@ class EventPumper implements Runnable {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Closing down the event pumper with no selection keys remaining");
}
- } catch (Exception e) {
+ } catch (IOException e) {
_log.error("Error closing keys on pumper shutdown", e);
}
_wantsConRegister.clear();
diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
index 703ee5050..37504a111 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java
@@ -463,7 +463,7 @@ class NTCPConnection implements Closeable {
_transport.afterSend(msg, successful, allowRequeue, msg.getLifetime());
if (_consecutiveBacklog > 10) { // waaay too backlogged
boolean wantsWrite = false;
- try { wantsWrite = ( (_conKey.interestOps() & SelectionKey.OP_WRITE) != 0); } catch (Exception e) {}
+ try { wantsWrite = ( (_conKey.interestOps() & SelectionKey.OP_WRITE) != 0); } catch (RuntimeException e) {}
if (_log.shouldLog(Log.WARN)) {
int blocks = _writeBufs.size();
_log.warn("Too backlogged for too long (" + _consecutiveBacklog + " messages for " + DataHelper.formatDuration(queueTime()) + ", sched? " + wantsWrite + ", blocks: " + blocks + ") sending to " + _remotePeer.calculateHash());
@@ -521,7 +521,7 @@ class NTCPConnection implements Closeable {
+ ", wantsWrite? " + (0 != (_conKey.interestOps()&SelectionKey.OP_WRITE))
+ ", currentOut set? " + currentOutboundSet
+ ", writeBufs: " + writeBufs + " on " + toString());
- } catch (Exception e) {} // java.nio.channels.CancelledKeyException
+ } catch (RuntimeException e) {} // java.nio.channels.CancelledKeyException
}
//_context.statManager().addRateData("ntcp.sendBacklogTime", queueTime);
return true;
diff --git a/router/java/src/net/i2p/router/transport/udp/ACKSender.java b/router/java/src/net/i2p/router/transport/udp/ACKSender.java
index 8e608ab13..60976d285 100644
--- a/router/java/src/net/i2p/router/transport/udp/ACKSender.java
+++ b/router/java/src/net/i2p/router/transport/udp/ACKSender.java
@@ -148,7 +148,7 @@ class ACKSender implements Runnable {
try {
// bulk operations may throw an exception
_peersToACK.addAll(notYet);
- } catch (Exception e) {}
+ } catch (RuntimeException e) {}
if (_log.shouldLog(Log.DEBUG))
_log.debug("sleeping, pending size = " + notYet.size());
notYet.clear();
diff --git a/router/java/src/net/i2p/router/transport/udp/MessageReceiver.java b/router/java/src/net/i2p/router/transport/udp/MessageReceiver.java
index 1b6bb03c0..d2a3b0414 100644
--- a/router/java/src/net/i2p/router/transport/udp/MessageReceiver.java
+++ b/router/java/src/net/i2p/router/transport/udp/MessageReceiver.java
@@ -243,7 +243,7 @@ class MessageReceiver {
}
_context.messageHistory().droppedInboundMessage(state.getMessageId(), state.getFrom(), "error: " + ime.toString() + ": " + state.toString());
return null;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
// e.g. AIOOBE
if (_log.shouldLog(Log.WARN))
_log.warn("Error handling a message: " + state, e);
diff --git a/router/java/src/net/i2p/router/transport/udp/PacketHandler.java b/router/java/src/net/i2p/router/transport/udp/PacketHandler.java
index 736171b80..1f5f990bc 100644
--- a/router/java/src/net/i2p/router/transport/udp/PacketHandler.java
+++ b/router/java/src/net/i2p/router/transport/udp/PacketHandler.java
@@ -215,7 +215,7 @@ class PacketHandler {
_state = 5;
handlePacket(_reader, packet);
_state = 6;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_state = 7;
if (_log.shouldLog(Log.ERROR))
_log.error("Crazy error handling a packet: " + packet, e);
diff --git a/router/java/src/net/i2p/router/transport/udp/PacketPusher.java b/router/java/src/net/i2p/router/transport/udp/PacketPusher.java
index f28ee9645..5c770175c 100644
--- a/router/java/src/net/i2p/router/transport/udp/PacketPusher.java
+++ b/router/java/src/net/i2p/router/transport/udp/PacketPusher.java
@@ -43,7 +43,7 @@ class PacketPusher implements Runnable {
send(packets.get(i));
}
}
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.error("SSU Output Queue Error", e);
}
}
diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java
index 5b2bdfb2a..d4985ab51 100644
--- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java
+++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java
@@ -213,7 +213,7 @@ class BuildHandler implements Runnable {
while (_isRunning && !_manager.isShutdown()) {
try {
handleInboundRequest();
- } catch (Exception e) {
+ } catch (RuntimeException e) {
_log.log(Log.CRIT, "B0rked in the tunnel handler", e);
}
}