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;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -50,7 +49,7 @@ public interface SerBiConsumer<T, U> extends BiConsumer<T, U>, Serializable {
|
|||||||
* @param u the second input argument
|
* @param u the second input argument
|
||||||
* @throws Exception wrapped checked exception for easy using
|
* @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.
|
* 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) {
|
default void accept(final T t, final U u) {
|
||||||
try {
|
try {
|
||||||
accepting(t, u);
|
accepting(t, u);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -39,7 +38,7 @@ public interface SerBiFunction<T, U, R> extends BiFunction<T, U, R>, Serializabl
|
|||||||
* @return the function result
|
* @return the function result
|
||||||
* @throws Exception wrapped checked exception
|
* @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.
|
* 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) {
|
default R apply(final T t, final U u) {
|
||||||
try {
|
try {
|
||||||
return this.applying(t, u);
|
return this.applying(t, u);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -40,7 +39,7 @@ public interface SerBiPredicate<T, U> extends BiPredicate<T, U>, Serializable {
|
|||||||
* otherwise {@code false}
|
* otherwise {@code false}
|
||||||
* @throws Exception wrapped checked exception
|
* @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.
|
* 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) {
|
default boolean test(final T t, final U u) {
|
||||||
try {
|
try {
|
||||||
return testing(t, u);
|
return testing(t, u);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -38,7 +37,7 @@ public interface SerBinaryOperator<T> extends BinaryOperator<T>, Serializable {
|
|||||||
* @return the function result
|
* @return the function result
|
||||||
* @throws Exception wrapped checked exception
|
* @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.
|
* 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) {
|
default T apply(final T t, final T u) {
|
||||||
try {
|
try {
|
||||||
return this.applying(t, u);
|
return this.applying(t, u);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -36,7 +35,7 @@ public interface SerConsumer<T> extends Consumer<T>, Serializable {
|
|||||||
* @param t the input argument
|
* @param t the input argument
|
||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
*/
|
*/
|
||||||
void accepting(T t) throws Exception;
|
void accepting(T t) throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs this operation on the given argument.
|
* 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) {
|
default void accept(final T t) {
|
||||||
try {
|
try {
|
||||||
accepting(t);
|
accepting(t);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -38,7 +37,7 @@ public interface SerConsumer3<P1, P2, P3> extends Serializable {
|
|||||||
* @param p3 参数三
|
* @param p3 参数三
|
||||||
* @throws Exception wrapped checked exception
|
* @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) {
|
default void accept(final P1 p1, final P2 p2, final P3 p3) {
|
||||||
try {
|
try {
|
||||||
accepting(p1, p2, p3);
|
accepting(p1, p2, p3);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -36,7 +35,7 @@ public interface SerFunction<T, R> extends Function<T, R>, Serializable {
|
|||||||
* @return the function result
|
* @return the function result
|
||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
*/
|
*/
|
||||||
R applying(T t) throws Exception;
|
R applying(T t) throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies this function to the given argument.
|
* 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) {
|
default R apply(final T t) {
|
||||||
try {
|
try {
|
||||||
return applying(t);
|
return applying(t);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -38,7 +37,7 @@ public interface SerPredicate<T> extends Predicate<T>, Serializable {
|
|||||||
* otherwise {@code false}
|
* otherwise {@code false}
|
||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
*/
|
*/
|
||||||
boolean testing(T t) throws Exception;
|
boolean testing(T t) throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates this predicate on the given argument.
|
* 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) {
|
default boolean test(final T t) {
|
||||||
try {
|
try {
|
||||||
return testing(t);
|
return testing(t);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(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.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -40,7 +39,7 @@ public interface SerRunnable extends Runnable, Serializable {
|
|||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
* @see Thread#run()
|
* @see Thread#run()
|
||||||
*/
|
*/
|
||||||
void running() throws Exception;
|
void running() throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When an object implementing interface {@code Runnable} is used
|
* When an object implementing interface {@code Runnable} is used
|
||||||
@ -57,7 +56,7 @@ public interface SerRunnable extends Runnable, Serializable {
|
|||||||
default void run() {
|
default void run() {
|
||||||
try {
|
try {
|
||||||
running();
|
running();
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -35,7 +34,7 @@ public interface SerSupplier<R> extends Supplier<R>, Serializable {
|
|||||||
* @return a result
|
* @return a result
|
||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
*/
|
*/
|
||||||
R getting() throws Exception;
|
R getting() throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a result.
|
* Gets a result.
|
||||||
@ -46,7 +45,7 @@ public interface SerSupplier<R> extends Supplier<R>, Serializable {
|
|||||||
default R get() {
|
default R get() {
|
||||||
try {
|
try {
|
||||||
return getting();
|
return getting();
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.func;
|
package org.dromara.hutool.core.func;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.exception.HutoolException;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -36,7 +35,7 @@ public interface SerUnaryOperator<T> extends UnaryOperator<T>, Serializable {
|
|||||||
* @return the function result
|
* @return the function result
|
||||||
* @throws Exception wrapped checked exception
|
* @throws Exception wrapped checked exception
|
||||||
*/
|
*/
|
||||||
T applying(T t) throws Exception;
|
T applying(T t) throws Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies this function to the given argument.
|
* 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) {
|
default T apply(final T t) {
|
||||||
try {
|
try {
|
||||||
return applying(t);
|
return applying(t);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package org.dromara.hutool.core.io.file;
|
package org.dromara.hutool.core.io.file;
|
||||||
|
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
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.SerConsumer;
|
||||||
import org.dromara.hutool.core.func.SerFunction;
|
import org.dromara.hutool.core.func.SerFunction;
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
import org.dromara.hutool.core.io.IORuntimeException;
|
||||||
@ -168,7 +167,7 @@ public class FileReader extends FileWrapper {
|
|||||||
try {
|
try {
|
||||||
reader = FileUtil.getReader(this.file, charset);
|
reader = FileUtil.getReader(this.file, charset);
|
||||||
result = readerHandler.applying(reader);
|
result = readerHandler.applying(reader);
|
||||||
} catch (final Exception e) {
|
} catch (final Throwable e) {
|
||||||
throw ExceptionUtil.wrapRuntime(e);
|
throw ExceptionUtil.wrapRuntime(e);
|
||||||
} finally {
|
} finally {
|
||||||
IoUtil.closeQuietly(reader);
|
IoUtil.closeQuietly(reader);
|
||||||
|
@ -27,5 +27,5 @@ public interface ChannelHandler {
|
|||||||
* @param socketChannel {@link SocketChannel}
|
* @param socketChannel {@link SocketChannel}
|
||||||
* @throws Exception 可能的处理异常
|
* @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();
|
final SocketChannel socketChannel = (SocketChannel) key.channel();
|
||||||
try{
|
try{
|
||||||
handler.handle(socketChannel);
|
handler.handle(socketChannel);
|
||||||
} catch (final Exception e){
|
} catch (final Throwable e){
|
||||||
throw new SocketRuntimeException(e);
|
throw new SocketRuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class NioServer implements Closeable {
|
|||||||
final SocketChannel socketChannel = (SocketChannel) key.channel();
|
final SocketChannel socketChannel = (SocketChannel) key.channel();
|
||||||
try{
|
try{
|
||||||
handler.handle(socketChannel);
|
handler.handle(socketChannel);
|
||||||
} catch (final Exception e){
|
} catch (final Throwable e){
|
||||||
IoUtil.closeQuietly(socketChannel);
|
IoUtil.closeQuietly(socketChannel);
|
||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user