From 9ffd1ec2c239b35ee6e5af54d73e150620b17adf Mon Sep 17 00:00:00 2001 From: akwizgran Date: Tue, 4 Jun 2019 14:20:57 +0100 Subject: [PATCH] Unregister connection if sending stream header fails. --- .../bramble/plugin/ConnectionManagerImpl.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 8fefc4697..d3fec490b 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 @@ -553,21 +553,14 @@ class ConnectionManagerImpl implements ConnectionManager { onError(true); return; } - // Flush the output stream to send the outgoing stream header - StreamWriter out; - try { - out = streamWriterFactory.createStreamWriter( - writer.getOutputStream(), ctxOut); - out.getOutputStream().flush(); - } catch (IOException e) { - logException(LOG, WARNING, e); - onError(true); - return; - } // Handshake and exchange contacts try { InputStream in = streamReaderFactory.createStreamReader( reader.getInputStream(), ctxIn); + // Flush the output stream to send the outgoing stream header + StreamWriter out = streamWriterFactory.createStreamWriter( + writer.getOutputStream(), ctxOut); + out.getOutputStream().flush(); HandshakeResult result = handshakeManager.handshake( pendingContactId, in, out); Contact contact = contactExchangeManager.exchangeContacts( @@ -671,7 +664,7 @@ class ConnectionManagerImpl implements ConnectionManager { onError(); return; } - // Create and run the handshake session + // Handshake and exchange contacts try { InputStream in = streamReaderFactory.createStreamReader( reader.getInputStream(), ctxIn);