mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
将接口抛出的Exception改为Throwable,扩大适用范围,避免尴尬情况;
This commit is contained in:
parent
968a074efd
commit
440642b23a
@ -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<T, U> extends BiConsumer<T, U>, 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<T, U> extends BiConsumer<T, U>, 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<T, U, R> extends BiFunction<T, U, R>, 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<T, U, R> extends BiFunction<T, U, R>, 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<T, U> extends BiPredicate<T, U>, 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<T, U> extends BiPredicate<T, U>, 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<T> extends BinaryOperator<T>, 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<T> extends BinaryOperator<T>, 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<T> extends Consumer<T>, 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<T> extends Consumer<T>, Serializable {
|
||||
default void accept(final T t) {
|
||||
try {
|
||||
accepting(t);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
throw ExceptionUtil.wrapRuntime(e);
|
||||
}
|
||||
}
|
||||
|
@ -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<P1, P2, P3> 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<P1, P2, P3> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<T, R> extends Function<T, R>, 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<T, R> extends Function<T, R>, Serializable {
|
||||
default R apply(final T t) {
|
||||
try {
|
||||
return applying(t);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
throw ExceptionUtil.wrapRuntime(e);
|
||||
}
|
||||
}
|
||||
|
@ -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<T> extends Predicate<T>, 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<T> extends Predicate<T>, Serializable {
|
||||
default boolean test(final T t) {
|
||||
try {
|
||||
return testing(t);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
throw ExceptionUtil.wrapRuntime(e);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<R> extends Supplier<R>, 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<R> extends Supplier<R>, Serializable {
|
||||
default R get() {
|
||||
try {
|
||||
return getting();
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
throw ExceptionUtil.wrapRuntime(e);
|
||||
}
|
||||
}
|
||||
|
@ -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<T> extends UnaryOperator<T>, 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<T> extends UnaryOperator<T>, Serializable {
|
||||
default T apply(final T t) {
|
||||
try {
|
||||
return applying(t);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
throw ExceptionUtil.wrapRuntime(e);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user