将接口抛出的Exception改为Throwable,扩大适用范围,避免尴尬情况;

This commit is contained in:
Zjp
2023-11-10 14:34:38 +08:00
parent 968a074efd
commit 440642b23a
15 changed files with 26 additions and 38 deletions

View File

@@ -27,5 +27,5 @@ public interface ChannelHandler {
* @param socketChannel {@link SocketChannel}
* @throws Exception 可能的处理异常
*/
void handle(SocketChannel socketChannel) throws Exception;
void handle(SocketChannel socketChannel) throws Throwable;
}

View File

@@ -139,7 +139,7 @@ public class NioClient implements Closeable {
final SocketChannel socketChannel = (SocketChannel) key.channel();
try{
handler.handle(socketChannel);
} catch (final Exception e){
} catch (final Throwable e){
throw new SocketRuntimeException(e);
}
}

View File

@@ -151,7 +151,7 @@ public class NioServer implements Closeable {
final SocketChannel socketChannel = (SocketChannel) key.channel();
try{
handler.handle(socketChannel);
} catch (final Exception e){
} catch (final Throwable e){
IoUtil.closeQuietly(socketChannel);
log.error(e);
}