Log exceptions with stack traces.

This commit is contained in:
akwizgran
2012-12-07 15:22:34 +00:00
parent 90978fa9c6
commit 19106ae044
27 changed files with 135 additions and 130 deletions

View File

@@ -72,9 +72,9 @@ public class HelloWorldService extends RoboService {
if(LOG.isLoggable(INFO))
LOG.info(pluginsStarted + " plugins started");
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -89,9 +89,9 @@ public class HelloWorldService extends RoboService {
db.close();
if(LOG.isLoggable(INFO)) LOG.info("Database closed");
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -44,10 +44,10 @@ class DatabaseCleanerImpl extends TimerTask implements DatabaseCleaner {
} catch(DbClosedException e) {
if(LOG.isLoggable(INFO)) LOG.info("Database closed, exiting");
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
throw new Error(e); // Kill the application
} catch(RuntimeException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
throw new Error(e); // Kill the application
}
}

View File

@@ -140,9 +140,11 @@ DatabaseCleaner.Callback {
close();
}
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
}
}
});

View File

@@ -362,7 +362,7 @@ abstract class JdbcDatabase implements Database<Connection> {
if(s != null) try {
s.close();
} catch(SQLException e) {
if(LOG.isLoggable(WARNING))LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))LOG.log(WARNING, e.toString(), e);
}
}
@@ -370,7 +370,7 @@ abstract class JdbcDatabase implements Database<Connection> {
if(rs != null) try {
rs.close();
} catch(SQLException e) {
if(LOG.isLoggable(WARNING))LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))LOG.log(WARNING, e.toString(), e);
}
}
@@ -406,11 +406,11 @@ abstract class JdbcDatabase implements Database<Connection> {
}
} catch(SQLException e) {
// Try to close the connection
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
try {
txn.close();
} catch(SQLException e1) {
if(LOG.isLoggable(WARNING)) LOG.warning(e1.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e1.toString(), e1);
}
// Whatever happens, allow the database to close
synchronized(connections) {

View File

@@ -66,11 +66,11 @@ class AliceConnector extends Connector {
byte[] key = receivePublicKey(r);
secret = deriveSharedSecret(hash, key, true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
return;
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
return;
}
@@ -84,7 +84,7 @@ class AliceConnector extends Connector {
if(receiveConfirmation(r)) group.remoteConfirmationSucceeded();
else group.remoteConfirmationFailed();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
group.remoteConfirmationFailed();
return;

View File

@@ -66,11 +66,11 @@ class BobConnector extends Connector {
sendPublicKey(w);
secret = deriveSharedSecret(hash, key, false);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
return;
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
return;
}
@@ -84,7 +84,7 @@ class BobConnector extends Connector {
if(receiveConfirmation(r)) group.remoteConfirmationSucceeded();
else group.remoteConfirmationFailed();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(conn, true);
group.remoteConfirmationFailed();
return;

View File

@@ -89,7 +89,7 @@ abstract class Connector extends Thread {
try {
conn.dispose(exception, true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}

View File

@@ -134,7 +134,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
user32.DispatchMessage(msg);
}
} catch(UnsatisfiedLinkError e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -127,10 +127,10 @@ class PluginManagerImpl implements PluginManager {
+ " did not start");
}
} catch(ClassCastException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
continue;
} catch(Exception e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
continue;
}
}
@@ -165,10 +165,10 @@ class PluginManagerImpl implements PluginManager {
+ " did not start");
}
} catch(ClassCastException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
continue;
} catch(Exception e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
continue;
}
}
@@ -204,7 +204,7 @@ class PluginManagerImpl implements PluginManager {
plugin.stop();
stopped++;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
simplexPlugins.clear();
@@ -215,7 +215,7 @@ class PluginManagerImpl implements PluginManager {
plugin.stop();
stopped++;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
duplexPlugins.clear();
@@ -246,7 +246,7 @@ class PluginManagerImpl implements PluginManager {
try {
return db.getConfig(id);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return new TransportConfig();
}
}
@@ -256,7 +256,7 @@ class PluginManagerImpl implements PluginManager {
TransportProperties p = db.getLocalProperties(id);
return p == null ? new TransportProperties() : p;
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return new TransportProperties();
}
}
@@ -265,7 +265,7 @@ class PluginManagerImpl implements PluginManager {
try {
return db.getRemoteProperties(id);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return Collections.emptyMap();
}
}
@@ -274,7 +274,7 @@ class PluginManagerImpl implements PluginManager {
try {
db.mergeConfig(id, c);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -282,7 +282,7 @@ class PluginManagerImpl implements PluginManager {
try {
db.mergeLocalProperties(id, p);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}

View File

@@ -109,7 +109,7 @@ class BluetoothPlugin implements DuplexPlugin {
try {
scn = (StreamConnectionNotifier) Connector.open(url);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return;
}
if(!running) {
@@ -133,7 +133,7 @@ class BluetoothPlugin implements DuplexPlugin {
try {
scn.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -144,7 +144,7 @@ class BluetoothPlugin implements DuplexPlugin {
s = scn.acceptAndOpen();
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
tryToClose(scn);
return;
}
@@ -198,7 +198,7 @@ class BluetoothPlugin implements DuplexPlugin {
StreamConnection s = (StreamConnection) Connector.open(url);
return new BluetoothTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
}
@@ -237,7 +237,7 @@ class BluetoothPlugin implements DuplexPlugin {
url = listener.waitForUrl();
} catch(BluetoothStateException e) {
if(LOG.isLoggable(WARNING))
LOG.warning(e.toString());
LOG.log(WARNING, e.toString(), e);
return null;
} catch(InterruptedException e) {
if(LOG.isLoggable(INFO))
@@ -270,7 +270,7 @@ class BluetoothPlugin implements DuplexPlugin {
try {
scn = (StreamConnectionNotifier) Connector.open(url);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
if(!running) {
@@ -290,7 +290,7 @@ class BluetoothPlugin implements DuplexPlugin {
return new BluetoothTransportConnection(s);
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
return null;
} finally {
if(f.cancel(false)) tryToClose(scn);
@@ -303,7 +303,7 @@ class BluetoothPlugin implements DuplexPlugin {
try {
localDevice.setDiscoverable(GIAC);
} catch(BluetoothStateException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -48,7 +48,7 @@ class InvitationListener implements DiscoveryListener {
discoveryAgent.searchServices(null, uuids, device, this);
searches.incrementAndGet();
} catch(BluetoothStateException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}

View File

@@ -128,7 +128,7 @@ class DroidtoothPlugin implements DuplexPlugin {
try {
ss = InsecureBluetooth.listen(adapter, "RFCOMM", getUuid());
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return;
}
if(!running) {
@@ -166,7 +166,7 @@ class DroidtoothPlugin implements DuplexPlugin {
try {
ss.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -177,7 +177,7 @@ class DroidtoothPlugin implements DuplexPlugin {
s = ss.accept();
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
tryToClose(ss);
return;
}
@@ -246,7 +246,7 @@ class DroidtoothPlugin implements DuplexPlugin {
s.connect();
return new DroidtoothTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
}
@@ -298,7 +298,7 @@ class DroidtoothPlugin implements DuplexPlugin {
try {
ss = InsecureBluetooth.listen(adapter, "RFCOMM", uuid);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
// Return the first connection received by the socket, if any
@@ -308,7 +308,7 @@ class DroidtoothPlugin implements DuplexPlugin {
if(LOG.isLoggable(INFO)) LOG.info("Invitation timed out");
return null;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
} finally {
tryToClose(ss);

View File

@@ -74,7 +74,7 @@ public abstract class FilePlugin implements SimplexPlugin {
OutputStream out = new FileOutputStream(f);
return new FileTransportWriter(f, out, capacity, this);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
f.delete();
return null;
}
@@ -104,7 +104,8 @@ public abstract class FilePlugin implements SimplexPlugin {
callback.readerCreated(new FileTransportReader(file, in,
FilePlugin.this));
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -32,7 +32,7 @@ class FileTransportReader implements SimplexTransportReader {
try {
in.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
if(recognised) {
file.delete();

View File

@@ -43,7 +43,7 @@ class FileTransportWriter implements SimplexTransportWriter {
try {
out.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
if(exception) file.delete();
else plugin.writerFinished(file);

View File

@@ -85,7 +85,7 @@ implements RemovableDriveMonitor.Callback {
if(i == -1) return null;
return drives.get(i);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
}
@@ -114,7 +114,7 @@ implements RemovableDriveMonitor.Callback {
}
}
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
return Collections.unmodifiableList(matches);
}
@@ -127,6 +127,6 @@ implements RemovableDriveMonitor.Callback {
}
public void exceptionThrown(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}

View File

@@ -70,16 +70,16 @@ class LanTcpPlugin extends TcpPlugin {
addrs.add(new InetSocketAddress(addr, port));
addrs.add(new InetSocketAddress(addr, 0));
} catch(NumberFormatException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(UnknownHostException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
List<NetworkInterface> ifaces;
try {
ifaces = Collections.list(NetworkInterface.getNetworkInterfaces());
} catch(SocketException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return addrs;
}
// Prefer interfaces with link-local or site-local addresses
@@ -123,7 +123,7 @@ class LanTcpPlugin extends TcpPlugin {
ms.setInterface(iface);
ms.joinGroup(mcast.getAddress());
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
if(ms != null) tryToClose(ms, mcast.getAddress());
return null;
}
@@ -149,7 +149,7 @@ class LanTcpPlugin extends TcpPlugin {
return new TcpTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(WARNING))
LOG.warning(e.toString());
LOG.log(WARNING, e.toString(), e);
}
}
} catch(SocketTimeoutException e) {
@@ -161,7 +161,7 @@ class LanTcpPlugin extends TcpPlugin {
if(LOG.isLoggable(INFO))
LOG.info("Timeout while sending invitation");
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} finally {
tryToClose(ms, mcast.getAddress());
}
@@ -201,7 +201,7 @@ class LanTcpPlugin extends TcpPlugin {
try {
ms.leaveGroup(addr);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
ms.close();
}
@@ -250,7 +250,7 @@ class LanTcpPlugin extends TcpPlugin {
ss = new ServerSocket();
ss.bind(new InetSocketAddress(iface, 0));
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
if(ss != null) tryToClose(ss);
return null;
}
@@ -262,7 +262,7 @@ class LanTcpPlugin extends TcpPlugin {
ms = new MulticastSocket();
ms.setInterface(iface);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
if(ms != null) ms.close();
tryToClose(ss);
return null;
@@ -299,7 +299,7 @@ class LanTcpPlugin extends TcpPlugin {
if(LOG.isLoggable(INFO))
LOG.info("Timeout while accepting invitation");
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} finally {
ms.close();
tryToClose(ss);

View File

@@ -53,9 +53,9 @@ class PortMapperImpl implements PortMapper {
if(externalString != null)
external = InetAddress.getByName(externalString);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(SAXException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
return new MappingResult(internal, external, port, succeeded);
}
@@ -65,11 +65,11 @@ class PortMapperImpl implements PortMapper {
try {
d.discover();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(SAXException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(ParserConfigurationException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
gateway = d.getValidGateway();
}
@@ -80,9 +80,9 @@ class PortMapperImpl implements PortMapper {
if(LOG.isLoggable(INFO))
LOG.info("Deleted mapping for port " + port);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(SAXException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -63,7 +63,7 @@ abstract class TcpPlugin implements DuplexPlugin {
try {
ss = new ServerSocket();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return;
}
boolean found = false;
@@ -73,7 +73,7 @@ abstract class TcpPlugin implements DuplexPlugin {
found = true;
break;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
tryToClose(ss);
continue;
}
@@ -100,7 +100,7 @@ abstract class TcpPlugin implements DuplexPlugin {
try {
ss.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -120,7 +120,7 @@ abstract class TcpPlugin implements DuplexPlugin {
s.setSoTimeout(0);
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
tryToClose(ss);
return;
}
@@ -172,7 +172,7 @@ abstract class TcpPlugin implements DuplexPlugin {
s.connect(addr);
return new TcpTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
return null;
}
}
@@ -188,9 +188,9 @@ abstract class TcpPlugin implements DuplexPlugin {
int port = Integer.valueOf(portString);
return new InetSocketAddress(addr, port);
} catch(NumberFormatException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(UnknownHostException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
return null;

View File

@@ -68,9 +68,9 @@ class WanTcpPlugin extends TcpPlugin {
addrs.add(new InetSocketAddress(addr, port));
addrs.add(new InetSocketAddress(addr, 0));
} catch(NumberFormatException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(UnknownHostException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
// Get a list of the device's network interfaces
@@ -78,7 +78,7 @@ class WanTcpPlugin extends TcpPlugin {
try {
ifaces = Collections.list(NetworkInterface.getNetworkInterfaces());
} catch(SocketException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return addrs;
}
// Accept interfaces without link-local or site-local addresses

View File

@@ -119,7 +119,7 @@ class TorPlugin implements DuplexPlugin {
addr = util.parseTorHiddenServicePrivateNetAddressFromStrings(
privateKey, "", false);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
addr = createHiddenServiceAddress(util);
}
}
@@ -131,7 +131,7 @@ class TorPlugin implements DuplexPlugin {
try {
ss = nl.createNetServerSocket(null, addrPort);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return;
}
synchronized(this) {
@@ -165,7 +165,7 @@ class TorPlugin implements DuplexPlugin {
try {
nl.clear();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -173,7 +173,7 @@ class TorPlugin implements DuplexPlugin {
try {
ss.close();
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -184,7 +184,7 @@ class TorPlugin implements DuplexPlugin {
s = ss.accept();
} catch(IOException e) {
// This is expected when the socket is closed
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
tryToClose(ss);
return;
}
@@ -272,7 +272,7 @@ class TorPlugin implements DuplexPlugin {
if(LOG.isLoggable(INFO)) LOG.info("Connected to hidden service");
return new TorTransportConnection(s);
} catch(IOException e) {
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
return null;
}
}

View File

@@ -181,7 +181,7 @@ abstract class DuplexConnection implements DatabaseListener {
// The writer will dispose of the transport if no exceptions occur
writerTasks.add(CLOSE);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -223,7 +223,7 @@ abstract class DuplexConnection implements DatabaseListener {
LOG.info("Interrupted while waiting for task");
dispose(true, true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
} finally {
connRegistry.unregisterConnection(contactId, transportId);
@@ -237,7 +237,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
transport.dispose(exception, recognised);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -254,7 +254,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
db.receiveAck(contactId, ack);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -273,7 +273,7 @@ abstract class DuplexConnection implements DatabaseListener {
Batch b = batch.verify();
dbExecutor.execute(new ReceiveBatch(b));
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -291,7 +291,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
db.receiveBatch(contactId, batch);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -310,7 +310,7 @@ abstract class DuplexConnection implements DatabaseListener {
Request r = db.receiveOffer(contactId, offer);
writerTasks.add(new WriteRequest(r));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -329,7 +329,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
writer.writeRequest(request);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -348,7 +348,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
db.setSeen(contactId, seen);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -366,7 +366,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
db.receiveSubscriptionUpdate(contactId, update);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -384,7 +384,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
db.receiveTransportUpdate(contactId, update);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -399,7 +399,7 @@ abstract class DuplexConnection implements DatabaseListener {
Ack a = db.generateAck(contactId, maxBatches);
if(a != null) writerTasks.add(new WriteAck(a));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -419,7 +419,7 @@ abstract class DuplexConnection implements DatabaseListener {
writer.writeAck(ack);
dbExecutor.execute(new GenerateAcks());
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -442,7 +442,7 @@ abstract class DuplexConnection implements DatabaseListener {
if(b == null) new GenerateOffer().run();
else writerTasks.add(new WriteBatch(b, requested));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -465,7 +465,7 @@ abstract class DuplexConnection implements DatabaseListener {
if(requested.isEmpty()) dbExecutor.execute(new GenerateOffer());
else dbExecutor.execute(new GenerateBatches(requested));
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -489,7 +489,7 @@ abstract class DuplexConnection implements DatabaseListener {
writerTasks.add(new WriteOffer(o));
}
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -508,7 +508,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
writer.writeOffer(offer);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -522,7 +522,7 @@ abstract class DuplexConnection implements DatabaseListener {
SubscriptionUpdate s = db.generateSubscriptionUpdate(contactId);
if(s != null) writerTasks.add(new WriteSubscriptionUpdate(s));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -541,7 +541,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
writer.writeSubscriptionUpdate(update);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}
@@ -555,7 +555,7 @@ abstract class DuplexConnection implements DatabaseListener {
TransportUpdate t = db.generateTransportUpdate(contactId);
if(t != null) writerTasks.add(new WriteTransportUpdate(t));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -574,7 +574,7 @@ abstract class DuplexConnection implements DatabaseListener {
try {
writer.writeTransportUpdate(update);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
}
}

View File

@@ -89,7 +89,7 @@ class IncomingSimplexConnection {
}
dispose(false, true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, true);
} finally {
connRegistry.unregisterConnection(contactId, transportId);
@@ -101,7 +101,7 @@ class IncomingSimplexConnection {
try {
transport.dispose(exception, recognised);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
@@ -117,7 +117,7 @@ class IncomingSimplexConnection {
try {
db.receiveAck(contactId, ack);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -135,7 +135,7 @@ class IncomingSimplexConnection {
Batch b = batch.verify();
dbExecutor.execute(new ReceiveBatch(b));
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -152,7 +152,7 @@ class IncomingSimplexConnection {
try {
db.receiveBatch(contactId, batch);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -169,7 +169,7 @@ class IncomingSimplexConnection {
try {
db.receiveSubscriptionUpdate(contactId, update);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}
@@ -186,7 +186,7 @@ class IncomingSimplexConnection {
try {
db.receiveTransportUpdate(contactId, update);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -99,10 +99,10 @@ class OutgoingSimplexConnection {
writer.close();
dispose(false);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true);
} finally {
connRegistry.unregisterConnection(contactId, transportId);
@@ -114,7 +114,7 @@ class OutgoingSimplexConnection {
try {
transport.dispose(exception);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -98,18 +98,20 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
transport);
}
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
try {
transport.dispose(true, false);
} catch(IOException e1) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e1.toString(), e1);
}
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
try {
transport.dispose(true, false);
} catch(IOException e1) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e1.toString(), e1);
}
}
}
@@ -131,7 +133,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
try {
tag = readTag(transport.getInputStream());
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, false);
return;
}
@@ -139,7 +141,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
try {
ctx = recogniser.acceptConnection(transportId, tag);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
dispose(true, false);
return;
}
@@ -151,7 +153,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
try {
transport.dispose(exception, recognised);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
}

View File

@@ -64,7 +64,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
try {
secrets = db.getSecrets();
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return false;
}
// Work out what phase of its lifecycle each secret is in
@@ -77,7 +77,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
try {
db.addSecrets(created);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return false;
}
}
@@ -224,7 +224,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
try {
connection = db.incrementConnectionCounter(c, t, s.getPeriod());
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
byte[] secret = s.getSecret().clone();
@@ -269,7 +269,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
try {
db.addSecrets(Arrays.asList(s1, s2));
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
// Pass the new secrets to the recogniser
recogniser.addSecret(s1);
@@ -304,7 +304,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
try {
db.addSecrets(created);
} catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
// Pass any secrets that have been created to the recogniser
for(TemporarySecret s : created) recogniser.addSecret(s);

View File

@@ -50,7 +50,7 @@ public class BoundedExecutor implements Executor {
Thread.currentThread().interrupt();
throw new RejectedExecutionException();
} catch(RejectedExecutionException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
semaphore.release();
throw e;
}