Stabilized ChunkedInputClosedOnErrorTest

- flush doesn't guarantee the end of input, however it should be close.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ChunkedInputClosedOnErrorTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ChunkedInputClosedOnErrorTest.java
index f48f999..86953dc 100644
--- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ChunkedInputClosedOnErrorTest.java
+++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ChunkedInputClosedOnErrorTest.java
@@ -104,7 +104,14 @@
         }
 
         boolean isEndOfInput() throws Exception {
-            return writer.get().getChunkedInput().isEndOfInput();
+            // getChunkedInput blocks and waits for the flush call, but that doesn't mean
+            // that the ChunkedInput is closed, so we give it a bit more time.
+            ChunkedInput<ByteBuf> chunkedInput = writer.get().getChunkedInput();
+            long timeout = System.currentTimeMillis() + 100;
+            while (!chunkedInput.isEndOfInput() && System.currentTimeMillis() < timeout) {
+                Thread.yield();
+            }
+            return chunkedInput.isEndOfInput();
         }
 
         @Override