20
20
import java .net .SocketAddress ;
21
21
import java .nio .channels .CancelledKeyException ;
22
22
import java .nio .channels .ClosedChannelException ;
23
- import java .nio .channels .ClosedSelectorException ;
24
23
import java .nio .channels .DatagramChannel ;
25
24
import java .nio .channels .SelectionKey ;
26
25
import java .nio .channels .ServerSocketChannel ;
@@ -586,7 +585,9 @@ public void run() {
586
585
try {
587
586
runLoop (this , selector , queue );
588
587
}
589
- catch (ClosedSelectorException e ) {
588
+ catch (AsyncSelectorException e ) {
589
+ Log .e (LOGTAG , "Selector exception" , e );
590
+ StreamUtility .closeQuietly (selector .getSelector ());
590
591
}
591
592
return ;
592
593
}
@@ -607,10 +608,8 @@ private static void run(final AsyncServer server, final SelectorWrapper selector
607
608
try {
608
609
runLoop (server , selector , queue );
609
610
}
610
- catch (ClosedSelectorException e ) {
611
- StreamUtility .closeQuietly (selector .getSelector ());
612
- }
613
611
catch (AsyncSelectorException e ) {
612
+ Log .e (LOGTAG , "Selector exception" , e );
614
613
StreamUtility .closeQuietly (selector .getSelector ());
615
614
}
616
615
// see if we keep looping, this must be in a synchronized block since the queue is accessed.
@@ -690,7 +689,7 @@ private static long lockAndRunQueue(final AsyncServer server, final PriorityQueu
690
689
return wait ;
691
690
}
692
691
693
- private static class AsyncSelectorException extends RuntimeException {
692
+ private static class AsyncSelectorException extends IOException {
694
693
public AsyncSelectorException (Exception e ) {
695
694
super (e );
696
695
}
@@ -731,10 +730,7 @@ private static void runLoop(final AsyncServer server, final SelectorWrapper sele
731
730
}
732
731
}
733
732
}
734
- catch (NullPointerException e ) {
735
- throw new AsyncSelectorException (e );
736
- }
737
- catch (IOException e ) {
733
+ catch (Exception e ) {
738
734
throw new AsyncSelectorException (e );
739
735
}
740
736
0 commit comments