From 440642b23a477a047bfdb34f5c01eb3bc3818f82 Mon Sep 17 00:00:00 2001 From: Zjp <1215582715@qq.com> Date: Fri, 10 Nov 2023 14:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=8E=A5=E5=8F=A3=E6=8A=9B=E5=87=BA?= =?UTF-8?q?=E7=9A=84Exception=E6=94=B9=E4=B8=BAThrowable=EF=BC=8C=E6=89=A9?= =?UTF-8?q?=E5=A4=A7=E9=80=82=E7=94=A8=E8=8C=83=E5=9B=B4=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=B0=B4=E5=B0=AC=E6=83=85=E5=86=B5;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/hutool/core/func/SerBiConsumer.java | 5 ++--- .../java/org/dromara/hutool/core/func/SerBiFunction.java | 5 ++--- .../java/org/dromara/hutool/core/func/SerBiPredicate.java | 5 ++--- .../java/org/dromara/hutool/core/func/SerBinaryOperator.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerConsumer.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerConsumer3.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerFunction.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerPredicate.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerRunnable.java | 5 ++--- .../main/java/org/dromara/hutool/core/func/SerSupplier.java | 5 ++--- .../java/org/dromara/hutool/core/func/SerUnaryOperator.java | 5 ++--- .../java/org/dromara/hutool/core/io/file/FileReader.java | 3 +-- .../java/org/dromara/hutool/socket/nio/ChannelHandler.java | 2 +- .../main/java/org/dromara/hutool/socket/nio/NioClient.java | 2 +- .../main/java/org/dromara/hutool/socket/nio/NioServer.java | 2 +- 15 files changed, 26 insertions(+), 38 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiConsumer.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiConsumer.java index b4b9ad886..850c5aef3 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiConsumer.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiConsumer.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -50,7 +49,7 @@ public interface SerBiConsumer extends BiConsumer, Serializable { * @param u the second input argument * @throws Exception wrapped checked exception for easy using */ - void accepting(T t, U u) throws Exception; + void accepting(T t, U u) throws Throwable; /** * Performs this operation on the given arguments. @@ -62,7 +61,7 @@ public interface SerBiConsumer extends BiConsumer, Serializable { default void accept(final T t, final U u) { try { accepting(t, u); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiFunction.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiFunction.java index 57ecc3a26..9852e1ad8 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiFunction.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiFunction.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -39,7 +38,7 @@ public interface SerBiFunction extends BiFunction, Serializabl * @return the function result * @throws Exception wrapped checked exception */ - R applying(T t, U u) throws Exception; + R applying(T t, U u) throws Throwable; /** * Applies this function to the given arguments. @@ -52,7 +51,7 @@ public interface SerBiFunction extends BiFunction, Serializabl default R apply(final T t, final U u) { try { return this.applying(t, u); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiPredicate.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiPredicate.java index 1e78ecbc9..16103fad7 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiPredicate.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBiPredicate.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -40,7 +39,7 @@ public interface SerBiPredicate extends BiPredicate, Serializable { * otherwise {@code false} * @throws Exception wrapped checked exception */ - boolean testing(T t, U u) throws Exception; + boolean testing(T t, U u) throws Throwable; /** * Evaluates this predicate on the given arguments. @@ -54,7 +53,7 @@ public interface SerBiPredicate extends BiPredicate, Serializable { default boolean test(final T t, final U u) { try { return testing(t, u); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBinaryOperator.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBinaryOperator.java index 030246cae..06c8857fe 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBinaryOperator.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerBinaryOperator.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Comparator; @@ -38,7 +37,7 @@ public interface SerBinaryOperator extends BinaryOperator, Serializable { * @return the function result * @throws Exception wrapped checked exception */ - T applying(T t, T u) throws Exception; + T applying(T t, T u) throws Throwable; /** * Applies this function to the given arguments. @@ -51,7 +50,7 @@ public interface SerBinaryOperator extends BinaryOperator, Serializable { default T apply(final T t, final T u) { try { return this.applying(t, u); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer.java index 7d7baef67..9c98f9f1e 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -36,7 +35,7 @@ public interface SerConsumer extends Consumer, Serializable { * @param t the input argument * @throws Exception wrapped checked exception */ - void accepting(T t) throws Exception; + void accepting(T t) throws Throwable; /** * Performs this operation on the given argument. @@ -47,7 +46,7 @@ public interface SerConsumer extends Consumer, Serializable { default void accept(final T t) { try { accepting(t); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer3.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer3.java index 361eaa1ea..1f012e951 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer3.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerConsumer3.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -38,7 +37,7 @@ public interface SerConsumer3 extends Serializable { * @param p3 参数三 * @throws Exception wrapped checked exception */ - void accepting(P1 p1, P2 p2, P3 p3) throws Exception; + void accepting(P1 p1, P2 p2, P3 p3) throws Throwable; /** * 接收参数方法 @@ -50,7 +49,7 @@ public interface SerConsumer3 extends Serializable { default void accept(final P1 p1, final P2 p2, final P3 p3) { try { accepting(p1, p2, p3); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerFunction.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerFunction.java index 33e58ca4c..eb52b46cc 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerFunction.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerFunction.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.function.Function; @@ -36,7 +35,7 @@ public interface SerFunction extends Function, Serializable { * @return the function result * @throws Exception wrapped checked exception */ - R applying(T t) throws Exception; + R applying(T t) throws Throwable; /** * Applies this function to the given argument. @@ -48,7 +47,7 @@ public interface SerFunction extends Function, Serializable { default R apply(final T t) { try { return applying(t); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerPredicate.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerPredicate.java index 9e8705c46..e68eb0f2a 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerPredicate.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerPredicate.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.Objects; @@ -38,7 +37,7 @@ public interface SerPredicate extends Predicate, Serializable { * otherwise {@code false} * @throws Exception wrapped checked exception */ - boolean testing(T t) throws Exception; + boolean testing(T t) throws Throwable; /** * Evaluates this predicate on the given argument. @@ -51,7 +50,7 @@ public interface SerPredicate extends Predicate, Serializable { default boolean test(final T t) { try { return testing(t); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerRunnable.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerRunnable.java index ab92a6913..46c70ace1 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerRunnable.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerRunnable.java @@ -14,7 +14,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.stream.Stream; @@ -40,7 +39,7 @@ public interface SerRunnable extends Runnable, Serializable { * @throws Exception wrapped checked exception * @see Thread#run() */ - void running() throws Exception; + void running() throws Throwable; /** * When an object implementing interface {@code Runnable} is used @@ -57,7 +56,7 @@ public interface SerRunnable extends Runnable, Serializable { default void run() { try { running(); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerSupplier.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerSupplier.java index cbc5985ee..79416aff5 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerSupplier.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerSupplier.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.function.Supplier; @@ -35,7 +34,7 @@ public interface SerSupplier extends Supplier, Serializable { * @return a result * @throws Exception wrapped checked exception */ - R getting() throws Exception; + R getting() throws Throwable; /** * Gets a result. @@ -46,7 +45,7 @@ public interface SerSupplier extends Supplier, Serializable { default R get() { try { return getting(); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerUnaryOperator.java b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerUnaryOperator.java index 76e52e56d..db3d49dae 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/func/SerUnaryOperator.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/func/SerUnaryOperator.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.func; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import java.io.Serializable; import java.util.function.Function; @@ -36,7 +35,7 @@ public interface SerUnaryOperator extends UnaryOperator, Serializable { * @return the function result * @throws Exception wrapped checked exception */ - T applying(T t) throws Exception; + T applying(T t) throws Throwable; /** * Applies this function to the given argument. @@ -48,7 +47,7 @@ public interface SerUnaryOperator extends UnaryOperator, Serializable { default T apply(final T t) { try { return applying(t); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/io/file/FileReader.java b/hutool-core/src/main/java/org/dromara/hutool/core/io/file/FileReader.java index b1a2912a6..f108d0f6d 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/io/file/FileReader.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/io/file/FileReader.java @@ -13,7 +13,6 @@ package org.dromara.hutool.core.io.file; import org.dromara.hutool.core.exception.ExceptionUtil; -import org.dromara.hutool.core.exception.HutoolException; import org.dromara.hutool.core.func.SerConsumer; import org.dromara.hutool.core.func.SerFunction; import org.dromara.hutool.core.io.IORuntimeException; @@ -168,7 +167,7 @@ public class FileReader extends FileWrapper { try { reader = FileUtil.getReader(this.file, charset); result = readerHandler.applying(reader); - } catch (final Exception e) { + } catch (final Throwable e) { throw ExceptionUtil.wrapRuntime(e); } finally { IoUtil.closeQuietly(reader); diff --git a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/ChannelHandler.java b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/ChannelHandler.java index 22f9eb9b7..3a2598570 100644 --- a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/ChannelHandler.java +++ b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/ChannelHandler.java @@ -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; } diff --git a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioClient.java b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioClient.java index 73ae22ac2..c589a15e1 100644 --- a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioClient.java +++ b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioClient.java @@ -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); } } diff --git a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioServer.java b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioServer.java index 2c4fc6754..f78ddcd62 100644 --- a/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioServer.java +++ b/hutool-socket/src/main/java/org/dromara/hutool/socket/nio/NioServer.java @@ -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); }