diff --git a/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java index cc188a3eb907359dbd45e9e0588ae79f51b027b8..99574a872665475932f4c3e6d7bbbacea0568a1b 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java @@ -300,8 +300,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeReader(boolean exception, boolean recognised) { - if (exception && outgoingSession != null) - outgoingSession.interrupt(); + // Interrupt the outgoing session so it finishes cleanly + if (outgoingSession != null) outgoingSession.interrupt(); try { reader.dispose(exception, recognised); } catch (IOException e) { @@ -310,6 +310,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeWriter(boolean exception) { + // Interrupt the incoming session if an exception occurred, + // otherwise wait for the end of stream marker if (exception && incomingSession != null) incomingSession.interrupt(); try { @@ -407,8 +409,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeReader(boolean exception, boolean recognised) { - if (exception && outgoingSession != null) - outgoingSession.interrupt(); + // Interrupt the outgoing session so it finishes cleanly + if (outgoingSession != null) outgoingSession.interrupt(); try { reader.dispose(exception, recognised); } catch (IOException e) { @@ -417,6 +419,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeWriter(boolean exception) { + // Interrupt the incoming session if an exception occurred, + // otherwise wait for the end of stream marker if (exception && incomingSession != null) incomingSession.interrupt(); try {