Handle exceptions thrown by connections' dispose() methods.

This commit is contained in:
akwizgran
2012-09-07 12:46:45 +01:00
parent 0fa945a7ed
commit 2e2eba820d
3 changed files with 27 additions and 7 deletions

View File

@@ -88,7 +88,11 @@ class IncomingSimplexConnection {
transport.dispose(false, true);
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
transport.dispose(true, true);
try {
transport.dispose(true, true);
} catch(IOException e1) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
} finally {
connRegistry.unregisterConnection(contactId, transportId);
}

View File

@@ -28,7 +28,7 @@ import net.sf.briar.api.transport.ConnectionWriterFactory;
class OutgoingSimplexConnection {
private static final Logger LOG =
Logger.getLogger(OutgoingSimplexConnection.class.getName());
Logger.getLogger(OutgoingSimplexConnection.class.getName());
private final DatabaseComponent db;
private final ConnectionRegistry connRegistry;
@@ -103,10 +103,18 @@ class OutgoingSimplexConnection {
transport.dispose(false);
} catch(DbException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
transport.dispose(true);
try {
transport.dispose(true);
} catch(IOException e1) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
transport.dispose(true);
try {
transport.dispose(true);
} catch(IOException e1) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
} finally {
connRegistry.unregisterConnection(contactId, transportId);
}

View File

@@ -27,7 +27,7 @@ import com.google.inject.Inject;
class ConnectionDispatcherImpl implements ConnectionDispatcher {
private static final Logger LOG =
Logger.getLogger(ConnectionDispatcherImpl.class.getName());
Logger.getLogger(ConnectionDispatcherImpl.class.getName());
private final Executor connExecutor;
private final ConnectionRecogniser recogniser;
@@ -96,10 +96,18 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
transport);
} catch(DbException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
transport.dispose(true, false);
try {
transport.dispose(true, false);
} catch(IOException e1) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
transport.dispose(true, false);
try {
transport.dispose(true, false);
} catch(IOException e1) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
}
}
}
}