diff options
author | vrubezhny | 2014-01-15 16:50:28 +0000 |
---|---|---|
committer | vrubezhny | 2014-01-15 16:50:28 +0000 |
commit | b7acab15c397f96d98a012bfba5d7405ebf4977d (patch) | |
tree | 11bac140cd9b977dac4dc3832c61a7e29f9c4852 | |
parent | c75d257dd9edb4dc420293eff1cb049e35327ca2 (diff) | |
download | webtools.maps-201401151800.tar.gz webtools.maps-201401151800.tar.xz webtools.maps-201401151800.zip |
[425044] Runtime disconnected error while running testsv201401151800
All the streams are closed in case of accept fails. Otherwise, in case of accept succeeded, a client and a server are responsible to close their connections accordingly.
Signed-off-by: vrubezhny <vrubezhny@exadel.com>
-rw-r--r-- | bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java b/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java index 896ce8275..d04499172 100644 --- a/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java +++ b/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java @@ -108,36 +108,40 @@ public class PipedTransportService implements TransportService { PipedOutputStream clientos = new PipedOutputStream(); PipedOutputStream serveros = new PipedOutputStream(); PipedInputStream clientis = new PipedInputStream(); - - try { - serveris.connect(clientos); - serveros.connect(clientis); - - listeners.put(key, new PipedConnection(clientis, clientos)); - listeners.notifyAll(); - long startTime = System.currentTimeMillis(); - while (true) { - try { - listeners.wait(timeout); - } catch (InterruptedException e) { - throw new IOException("accept failed: interrupted"); //$NON-NLS-1$ - } - if (!listeners.containsKey(key)) - throw new IOException("accept failed: stopped listening"); //$NON-NLS-1$ + serveris.connect(clientos); + serveros.connect(clientis); - if (listeners.get(key) != null) { - if (System.currentTimeMillis() - startTime > timeout) { - listeners.put(key, null); - throw new IOException("accept failed: timed out"); //$NON-NLS-1$ - } - continue; + PipedConnection clientConnection = new PipedConnection(clientis, clientos); + PipedConnection serverConnection = new PipedConnection(serveris, serveros); + + listeners.put(key, clientConnection); + listeners.notifyAll(); + long startTime = System.currentTimeMillis(); + while (true) { + try { + listeners.wait(timeout); + } catch (InterruptedException e) { + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: interrupted"); //$NON-NLS-1$ + } + if (!listeners.containsKey(key)) { + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: stopped listening"); //$NON-NLS-1$ + } + + if (listeners.get(key) != null) { + if (System.currentTimeMillis() - startTime > timeout) { + listeners.put(key, null); + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: timed out"); //$NON-NLS-1$ } - return new PipedConnection(serveris, serveros); + continue; } - } - finally { - serveris.close(); - serveros.close(); + return serverConnection; // From this point both, the server and the client, + // are responsible to close their connections } } } |