forked from I2P_Developers/i2p.i2p
lint: don't catch Exception, catch RuntimeException or checked exception.
omits SAM, BOB, reflection, commented-out code, and a few other places
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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());
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
@@ -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 "";
|
||||
}
|
||||
|
@@ -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 - " +
|
||||
|
Reference in New Issue
Block a user