Skip to content

Commit d6de24f

Browse files
bendemmarci4
authored andcommitted
Don't shutdown the ssl executor service too early (TooTallNate#331)
The ExecutorService held by the DefaultSSLWebSocketServerFactory was being shutdown when the first SSLSocketChannel2 got closed, making it unusable for further connections. It's now being closed on server stop instead.
1 parent f5a39a7 commit d6de24f

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/main/java/org/java_websocket/SSLSocketChannel2.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ public void close() throws IOException {
308308
if( socketChannel.isOpen() )
309309
socketChannel.write( wrap( emptybuffer ) );// FIXME what if not all bytes can be written
310310
socketChannel.close();
311-
exec.shutdownNow();
312311
}
313312

314313
private boolean isHandShakeComplete() {

src/main/java/org/java_websocket/server/DefaultSSLWebSocketServerFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ public WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d, Socket c ) {
4848
public WebSocketImpl createWebSocket( WebSocketAdapter a, List<Draft> d, Socket s ) {
4949
return new WebSocketImpl( a, d );
5050
}
51+
@Override
52+
public void close() {
53+
exec.shutdown();
54+
}
5155
}

src/main/java/org/java_websocket/server/DefaultWebSocketServerFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ public WebSocketImpl createWebSocket( WebSocketAdapter a, List<Draft> d, Socket
2323
public SocketChannel wrapChannel( SocketChannel channel, SelectionKey key ) {
2424
return (SocketChannel) channel;
2525
}
26+
@Override
27+
public void close() {
28+
}
2629
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ public void stop( int timeout ) throws InterruptedException {
215215
ws.close( CloseFrame.GOING_AWAY );
216216
}
217217

218+
wsf.close();
219+
218220
synchronized ( this ) {
219221
if( selectorthread != null && selectorthread != Thread.currentThread() ) {
220222
selector.wakeup();
@@ -729,5 +731,7 @@ public interface WebSocketServerFactory extends WebSocketFactory {
729731
* @return The channel on which the read and write operations will be performed.<br>
730732
*/
731733
public ByteChannel wrapChannel( SocketChannel channel, SelectionKey key ) throws IOException;
734+
735+
public void close();
732736
}
733737
}

0 commit comments

Comments
 (0)