@@ -213,8 +213,10 @@ public void stop( int timeout ) throws IOException , InterruptedException {
213213 if ( Thread .currentThread () != selectorthread ) {
214214
215215 }
216- selectorthread .interrupt ();
217- selectorthread .join ();
216+ if ( selectorthread != Thread .currentThread () ) {
217+ selectorthread .interrupt ();
218+ selectorthread .join ();
219+ }
218220 }
219221 if ( decoders != null ) {
220222 for ( WebSocketWorker w : decoders ) {
@@ -283,7 +285,7 @@ public void run() {
283285 selector = Selector .open ();
284286 server .register ( selector , server .validOps () );
285287 } catch ( IOException ex ) {
286- onWebsocketError ( null , ex );
288+ handleFatal ( null , ex );
287289 return ;
288290 }
289291 try {
@@ -315,7 +317,7 @@ public void run() {
315317 channel .configureBlocking ( false );
316318 WebSocketImpl w = wsf .createWebSocket ( this , drafts , channel .socket () );
317319 w .key = channel .register ( selector , SelectionKey .OP_READ , w );
318- w .channel = wsf .wrapChannel ( w .key );
320+ w .channel = wsf .wrapChannel ( channel , w .key );
319321 i .remove ();
320322 allocateBuffers ( w );
321323 continue ;
@@ -430,7 +432,7 @@ private void handleIOException( WebSocket conn, IOException ex ) {
430432 }
431433 }
432434
433- private void handleFatal ( WebSocket conn , RuntimeException e ) {
435+ private void handleFatal ( WebSocket conn , Exception e ) {
434436 onError ( conn , e );
435437 try {
436438 stop ();
@@ -655,6 +657,6 @@ public interface WebSocketServerFactory extends WebSocketFactory {
655657 * a SelectionKey of an open SocketChannel.
656658 * @return The channel on which the read and write operations will be performed.<br>
657659 */
658- public ByteChannel wrapChannel ( SelectionKey key ) throws IOException ;
660+ public ByteChannel wrapChannel ( SocketChannel channel , SelectionKey key ) throws IOException ;
659661 }
660662}
0 commit comments