diff --git a/CHANGELOG.md b/CHANGELOG.md index 711cb4eff..6e60eb77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,13 @@ * 【extra 】 Ftp增加构造(issue#I4TKXP@gitee) * 【core 】 GenericBuilder支持Map构建(pr#540@Github) * 【json 】 新增TemporalAccessorSerializer +* 【core 】 使多个xxxBuilder实现Builder接口,扩展CheckedUtil(pr#545@Gitee) +* 【core 】 CheckedUtil删除第二个参数为RuntimeException的方法 ### 🐞Bug修复 * 【cache 】 修复ReentrantCache.toString方法线程不安全问题(issue#2140@Github) * 【core 】 修复SystemPropsUtil.getInt返回long问题(pr#546@Gitee) +* 【crypto 】 修复SM2.getD前导0问题(pr#2149@Github) ------------------------------------------------------------------------------------------------------------- # 5.7.21 (2022-02-14) diff --git a/hutool-core/src/main/java/cn/hutool/core/exceptions/CheckedUtil.java b/hutool-core/src/main/java/cn/hutool/core/exceptions/CheckedUtil.java index 3b76d8a78..ae595168a 100644 --- a/hutool-core/src/main/java/cn/hutool/core/exceptions/CheckedUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/exceptions/CheckedUtil.java @@ -54,7 +54,7 @@ public class CheckedUtil { * @return {@link FuncRt} */ public static
FuncRt
uncheck(Func
expression) {
- return uncheck(expression, new RuntimeException());
+ return uncheck(expression, RuntimeException::new);
}
/**
@@ -66,7 +66,7 @@ public class CheckedUtil {
* @return {@link Func0Rt}
*/
public static Func1Rt uncheck(Func1 expression) {
- return uncheck(expression, new RuntimeException());
+ return uncheck(expression, RuntimeException::new);
}
@@ -92,7 +92,7 @@ public class CheckedUtil {
* @return {@link VoidFuncRt}
*/
public static VoidFuncRt uncheck(VoidFunc expression) {
- return uncheck(expression, new RuntimeException());
+ return uncheck(expression, RuntimeException::new);
}
/**
@@ -103,7 +103,7 @@ public class CheckedUtil {
* @return {@link VoidFunc0Rt}
*/
public static VoidFunc0Rt uncheck(VoidFunc0 expression) {
- return uncheck(expression, new RuntimeException());
+ return uncheck(expression, RuntimeException::new);
}
/**
@@ -115,36 +115,10 @@ public class CheckedUtil {
* @return {@link VoidFunc1Rt}
*/
public static VoidFunc1Rt uncheck(VoidFunc1 expression) {
- return uncheck(expression, new RuntimeException());
+ return uncheck(expression, RuntimeException::new);
}
- /**
- * 接收一个可以转化成 cn.hutool.core.lang.func.Func的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
- * 如此一来,代码中就不用显示的try-catch转化成运行时异常
- *
- * @param expression Lambda表达式
- * @param rte 期望抛出的运行时异常
- * @param 运行时传入的参数类型
- * @param FuncRt uncheck(Func expression, RuntimeException rte) {
- Objects.requireNonNull(expression, "expression can not be null");
- return t -> {
- try {
- return expression.call(t);
- } catch (Exception e) {
- if (rte == null) {
- throw new RuntimeException(e);
- } else {
- rte.initCause(e);
- throw rte;
- }
- }
- };
- }
-
/**
* 接收一个可以转化成 cn.hutool.core.lang.func.Func的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
@@ -170,31 +144,6 @@ public class CheckedUtil {
};
}
- /**
- * 接收一个可以转化成 cn.hutool.core.lang.func.Func0的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
- * 如此一来,代码中就不用显示的try-catch转化成运行时异常
- *
- * @param expression Lambda表达式
- * @param rte 期望抛出的运行时异常
- * @param 运行时传入的参数类型
- * @param Func1Rt uncheck(Func1 expression, RuntimeException rte) {
- Objects.requireNonNull(expression, "expression can not be null");
- return t -> {
- try {
- return expression.call(t);
- } catch (Exception e) {
- if (rte == null) {
- throw new RuntimeException(e);
- } else {
- rte.initCause(e);
- throw rte;
- }
- }
- };
- }
-
/**
* 接收一个可以转化成 cn.hutool.core.lang.func.Func1的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
@@ -270,31 +193,6 @@ public class CheckedUtil {
};
}
- /**
- * 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
- * 如此一来,代码中就不用显示的try-catch转化成运行时异常
- *
- * @param expression Lambda表达式
- * @param rte 期望抛出的运行时异常
- * @param 运行时传入的参数类型
- * @return {@link VoidFuncRt}
- */
- public static VoidFuncRt uncheck(VoidFunc expression, RuntimeException rte) {
- Objects.requireNonNull(expression, "expression can not be null");
- return t -> {
- try {
- expression.call(t);
- } catch (Exception e) {
- if (rte == null) {
- throw new RuntimeException(e);
- } else {
- rte.initCause(e);
- throw rte;
- }
- }
- };
- }
-
/**
* 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
@@ -367,32 +265,6 @@ public class CheckedUtil {
};
}
-
- /**
- * 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc1的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
- * 如此一来,代码中就不用显示的try-catch转化成运行时异常
- *
- * @param expression Lambda表达式
- * @param rte 期望抛出的运行时异常
- * @param 运行时传入的参数类型
- * @return {@link VoidFunc1Rt}
- */
- public static VoidFunc1Rt uncheck(VoidFunc1 expression, RuntimeException rte) {
- Objects.requireNonNull(expression, "expression can not be null");
- return t -> {
- try {
- expression.call(t);
- } catch (Exception e) {
- if (rte == null) {
- throw new RuntimeException(e);
- } else {
- rte.initCause(e);
- throw rte;
- }
- }
- };
- }
-
/**
* 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc1的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
@@ -418,6 +290,7 @@ public class CheckedUtil {
}
public interface FuncRt extends Func {
+ @SuppressWarnings("unchecked")
@Override
R call(P... parameters) throws RuntimeException;
}
@@ -433,6 +306,7 @@ public class CheckedUtil {
}
public interface VoidFuncRt extends VoidFunc {
+ @SuppressWarnings("unchecked")
@Override
void call(P... parameters) throws RuntimeException;
}
diff --git a/hutool-core/src/main/java/cn/hutool/core/net/SSLContextBuilder.java b/hutool-core/src/main/java/cn/hutool/core/net/SSLContextBuilder.java
index d08c5fcdb..f7c783dc1 100644
--- a/hutool-core/src/main/java/cn/hutool/core/net/SSLContextBuilder.java
+++ b/hutool-core/src/main/java/cn/hutool/core/net/SSLContextBuilder.java
@@ -1,7 +1,6 @@
package cn.hutool.core.net;
import cn.hutool.core.builder.Builder;
-import cn.hutool.core.exceptions.CheckedUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
@@ -29,7 +28,8 @@ import java.security.SecureRandom;
* @since 5.5.2
*/
public class SSLContextBuilder implements SSLProtocols, Builder