Skip to content

Commit c00c3d9

Browse files
committed
fixed case in which onClose's would be CloseFrame.ABNORMAL_CLOSE wrongly and made WebSocketImpl work without SelectionKeys
1 parent 3128285 commit c00c3d9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/java/org/java_websocket/WebSocketImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,11 @@ protected synchronized void closeConnection( int code, String message, boolean r
431431
if( key != null ) {
432432
// key.attach( null ); //see issue #114
433433
key.cancel();
434-
try {
435-
channel.close();
436-
} catch ( IOException e ) {
437-
wsl.onWebsocketError( this, e );
438-
}
434+
}
435+
try {
436+
channel.close();
437+
} catch ( IOException e ) {
438+
wsl.onWebsocketError( this, e );
439439
}
440440
try {
441441
this.wsl.onWebsocketClose( this, code, message, remote );
@@ -489,9 +489,8 @@ protected synchronized void flushAndClose( int code, String message, boolean rem
489489
public void eot() {
490490
if( getReadyState() == READYSTATE.NOT_YET_CONNECTED ) {
491491
closeConnection( CloseFrame.NEVER_CONNECTED, true );
492-
}
493-
if( draft == null ) {
494-
closeConnection( CloseFrame.ABNORMAL_CLOSE, true );
492+
} else if( flushandclosestate ) {
493+
closeConnection( closecode, closemessage, closedremotely );
495494
} else if( draft.getCloseHandshakeType() == CloseHandshakeType.NONE ) {
496495
closeConnection( CloseFrame.NORMAL, true );
497496
} else if( draft.getCloseHandshakeType() == CloseHandshakeType.ONEWAY ) {

0 commit comments

Comments
 (0)