From 0ba8da2dd265898240699b3fe5a181b4ad45566a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 14 Apr 2016 17:47:34 -0700 Subject: [PATCH] GUACAMOLE-44: Do not wait forever for streams to be notified. --- .../apache/guacamole/tunnel/StreamInterceptingTunnel.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/java/org/apache/guacamole/tunnel/StreamInterceptingTunnel.java b/guacamole/src/main/java/org/apache/guacamole/tunnel/StreamInterceptingTunnel.java index a84a090ce..a9a135512 100644 --- a/guacamole/src/main/java/org/apache/guacamole/tunnel/StreamInterceptingTunnel.java +++ b/guacamole/src/main/java/org/apache/guacamole/tunnel/StreamInterceptingTunnel.java @@ -53,6 +53,12 @@ public class StreamInterceptingTunnel extends DelegatingGuacamoleTunnel { */ private static final Logger logger = LoggerFactory.getLogger(StreamInterceptingTunnel.class); + /** + * The maximum number of milliseconds to wait for notification that a + * stream has closed before explicitly checking for closure ourselves. + */ + private static final long STREAM_WAIT_TIMEOUT = 1000; + /** * Creates a new StreamInterceptingTunnel which wraps the given tunnel, * reading and intercepting stream-related instructions as necessary to @@ -319,7 +325,7 @@ public class StreamInterceptingTunnel extends DelegatingGuacamoleTunnel { synchronized (stream) { while (streams.get(indexString) == stream) { try { - stream.wait(); + stream.wait(STREAM_WAIT_TIMEOUT); } catch (InterruptedException e) { // Ignore