Skip to content

Commit 2b8ecd6

Browse files
author
ThreaT
committed
Merge pull request TooTallNate#307 from raydelto/master
Preventing the server to crash because of a NPE. Issue TooTallNate#224
2 parents 7885239 + dbced22 commit 2b8ecd6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎src/main/java/org/java_websocket/SocketChannelIOHelper.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws
6161
} while ( buffer != null );
6262
}
6363

64-
if( ws.outQueue.isEmpty() && ws.isFlushAndClose() && ws.getDraft().getRole() == Role.SERVER ){//
64+
if( ws != null && ws.outQueue.isEmpty() && ws.isFlushAndClose() && ws.getDraft() != null && ws.getDraft().getRole() != null && ws.getDraft().getRole() == Role.SERVER ){//
6565
synchronized ( ws ){
6666
ws.closeConnection();
6767
}

‎src/main/java/org/java_websocket/server/WebSocketServer.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,11 @@ public void run(){
707707
assert ( buf != null );
708708
try{
709709
ws.decode( buf );
710-
} finally{
710+
} catch(Exceptione){
711+
System.err.println("Error while reading from remote connection: " + e);
712+
}
713+
714+
finally{
711715
pushBuffer( buf );
712716
}
713717
}

0 commit comments

Comments
(0)