Skip to content

Commit 5c453ef

Browse files
committed
fixed TooTallNate#128: Crash on socket close if disconnected/not yet connected
1 parent 1759d61 commit 5c453ef

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,8 @@ public void connect() {
140140
}
141141

142142
public void close() {
143-
if( thread != null ) {
143+
if( thread != null && conn != null ) {
144144
conn.close( CloseFrame.NORMAL );
145-
/*closelock.lock();
146-
try {
147-
if( selector != null )
148-
selector.wakeup();
149-
} finally {
150-
closelock.unlock();
151-
}*/
152145
}
153146

154147
}
@@ -390,7 +383,7 @@ public final void onWriteDemand( WebSocket conn ) {
390383
key.interestOps( SelectionKey.OP_READ | SelectionKey.OP_WRITE );
391384
selector.wakeup();
392385
} catch ( CancelledKeyException e ) {
393-
// since such an exception/event will also occur on the selector there is no need to do anything here
386+
// since such an exception/event will also occur on the selector there is no need to do anything herec
394387
}
395388
}
396389

0 commit comments

Comments
 (0)