3737import org .junit .Test ;
3838
3939import java .io .IOException ;
40- import java .io .InputStream ;
41- import java .lang .reflect .Method ;
4240import java .net .InetSocketAddress ;
4341import java .net .URI ;
4442import java .nio .ByteBuffer ;
4745
4846public class Issue900Test {
4947
50- CountDownLatch countServerDownLatch = new CountDownLatch (1 );
51- CountDownLatch countCloseCallsDownLatch = new CountDownLatch (1 );
48+ CountDownLatch serverStartLatch = new CountDownLatch (1 );
49+ CountDownLatch closeCalledLatch = new CountDownLatch (1 );
5250
5351 @ Test (timeout = 2000 )
5452 public void testIssue () throws Exception {
@@ -79,7 +77,7 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {
7977
8078 @ Override
8179 public void onClose (WebSocket conn , int code , String reason , boolean remote ) {
82- countCloseCallsDownLatch .countDown ();
80+ closeCalledLatch .countDown ();
8381 }
8482
8583 @ Override
@@ -94,22 +92,22 @@ public void onError(WebSocket conn, Exception ex) {
9492
9593 @ Override
9694 public void onStart () {
97- countServerDownLatch .countDown ();
95+ serverStartLatch .countDown ();
9896 }
9997 };
10098 new Thread (server ).start ();
101- countServerDownLatch .await ();
99+ serverStartLatch .await ();
102100 client .connectBlocking ();
103101 WebSocketImpl websocketImpl = (WebSocketImpl )new ArrayList <WebSocket >(server .getConnections ()).get (0 );
104102 websocketImpl .setChannel (new ExceptionThrowingByteChannel ());
105103 server .broadcast ("test" );
106- countCloseCallsDownLatch .await ();
104+ closeCalledLatch .await ();
107105 }
108106 class ExceptionThrowingByteChannel implements WrappedByteChannel {
109107
110108 @ Override
111109 public boolean isNeedWrite () {
112- return false ;
110+ return true ;
113111 }
114112
115113 @ Override
@@ -119,7 +117,7 @@ public void writeMore() throws IOException {
119117
120118 @ Override
121119 public boolean isNeedRead () {
122- return false ;
120+ return true ;
123121 }
124122
125123 @ Override
0 commit comments