Skip to content

Commit 43c8b14

Browse files
committed
Switched around call for connect/closing latches
Fix for: Client blocking connect and close methods return too soon TooTallNate#302
1 parent 5b47329 commit 43c8b14

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/org/java_websocket/client/WebSocketClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,15 @@ public void onWebsocketMessageFragment( WebSocket conn, Framedata frame ) {
271271
*/
272272
@Override
273273
public final void onWebsocketOpen( WebSocket conn, Handshakedata handshake ) {
274-
connectLatch.countDown();
275274
onOpen( (ServerHandshake) handshake );
275+
connectLatch.countDown();
276276
}
277277

278278
/**
279279
* Calls subclass' implementation of <var>onClose</var>.
280280
*/
281281
@Override
282282
public final void onWebsocketClose( WebSocket conn, int code, String reason, boolean remote ) {
283-
connectLatch.countDown();
284-
closeLatch.countDown();
285283
if( writeThread != null )
286284
writeThread.interrupt();
287285
try {
@@ -291,6 +289,8 @@ public final void onWebsocketClose( WebSocket conn, int code, String reason, boo
291289
onWebsocketError( this, e );
292290
}
293291
onClose( code, reason, remote );
292+
connectLatch.countDown();
293+
closeLatch.countDown();
294294
}
295295

296296
/**

0 commit comments

Comments
 (0)