mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
8251847d1f
commit
9151aa8968
@ -9,10 +9,13 @@
|
|||||||
* 【extra 】 Ftp增加构造(issue#I4TKXP@gitee)
|
* 【extra 】 Ftp增加构造(issue#I4TKXP@gitee)
|
||||||
* 【core 】 GenericBuilder支持Map构建(pr#540@Github)
|
* 【core 】 GenericBuilder支持Map构建(pr#540@Github)
|
||||||
* 【json 】 新增TemporalAccessorSerializer
|
* 【json 】 新增TemporalAccessorSerializer
|
||||||
|
* 【core 】 使多个xxxBuilder实现Builder接口,扩展CheckedUtil(pr#545@Gitee)
|
||||||
|
* 【core 】 CheckedUtil删除第二个参数为RuntimeException的方法
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【cache 】 修复ReentrantCache.toString方法线程不安全问题(issue#2140@Github)
|
* 【cache 】 修复ReentrantCache.toString方法线程不安全问题(issue#2140@Github)
|
||||||
* 【core 】 修复SystemPropsUtil.getInt返回long问题(pr#546@Gitee)
|
* 【core 】 修复SystemPropsUtil.getInt返回long问题(pr#546@Gitee)
|
||||||
|
* 【crypto 】 修复SM2.getD前导0问题(pr#2149@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.7.21 (2022-02-14)
|
# 5.7.21 (2022-02-14)
|
||||||
|
@ -54,7 +54,7 @@ public class CheckedUtil {
|
|||||||
* @return {@link FuncRt}
|
* @return {@link FuncRt}
|
||||||
*/
|
*/
|
||||||
public static <P, R> FuncRt<P, R> uncheck(Func<P, R> expression) {
|
public static <P, R> FuncRt<P, R> uncheck(Func<P, R> expression) {
|
||||||
return uncheck(expression, new RuntimeException());
|
return uncheck(expression, RuntimeException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class CheckedUtil {
|
|||||||
* @return {@link Func0Rt}
|
* @return {@link Func0Rt}
|
||||||
*/
|
*/
|
||||||
public static <R> Func0Rt<R> uncheck(Func0<R> expression) {
|
public static <R> Func0Rt<R> uncheck(Func0<R> expression) {
|
||||||
return uncheck(expression, new RuntimeException());
|
return uncheck(expression, RuntimeException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +79,7 @@ public class CheckedUtil {
|
|||||||
* @return {@link Func1Rt}
|
* @return {@link Func1Rt}
|
||||||
*/
|
*/
|
||||||
public static <P, R> Func1Rt<P, R> uncheck(Func1<P, R> expression) {
|
public static <P, R> Func1Rt<P, R> uncheck(Func1<P, R> expression) {
|
||||||
return uncheck(expression, new RuntimeException());
|
return uncheck(expression, RuntimeException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class CheckedUtil {
|
|||||||
* @return {@link VoidFuncRt}
|
* @return {@link VoidFuncRt}
|
||||||
*/
|
*/
|
||||||
public static <P> VoidFuncRt<P> uncheck(VoidFunc<P> expression) {
|
public static <P> VoidFuncRt<P> uncheck(VoidFunc<P> expression) {
|
||||||
return uncheck(expression, new RuntimeException());
|
return uncheck(expression, RuntimeException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +103,7 @@ public class CheckedUtil {
|
|||||||
* @return {@link VoidFunc0Rt}
|
* @return {@link VoidFunc0Rt}
|
||||||
*/
|
*/
|
||||||
public static VoidFunc0Rt uncheck(VoidFunc0 expression) {
|
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}
|
* @return {@link VoidFunc1Rt}
|
||||||
*/
|
*/
|
||||||
public static <P> VoidFunc1Rt<P> uncheck(VoidFunc1<P> expression) {
|
public static <P> VoidFunc1Rt<P> uncheck(VoidFunc1<P> 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 <P> 运行时传入的参数类型
|
|
||||||
* @param <R> 最终返回的数据类型
|
|
||||||
* @return {@link FuncRt}
|
|
||||||
*/
|
|
||||||
public static <P, R> FuncRt<P, R> uncheck(Func<P, R> 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的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
* 接收一个可以转化成 cn.hutool.core.lang.func.Func的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
* 如此一来,代码中就不用显示的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 <R> 最终返回的数据类型
|
|
||||||
* @return {@link Func0Rt}
|
|
||||||
*/
|
|
||||||
public static <R> Func0Rt<R> uncheck(Func0<R> expression, RuntimeException rte) {
|
|
||||||
Objects.requireNonNull(expression, "expression can not be null");
|
|
||||||
return () -> {
|
|
||||||
try {
|
|
||||||
return expression.call();
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (rte == null) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} else {
|
|
||||||
rte.initCause(e);
|
|
||||||
throw rte;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收一个可以转化成 cn.hutool.core.lang.func.Func0的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
* 接收一个可以转化成 cn.hutool.core.lang.func.Func0的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
||||||
@ -219,32 +168,6 @@ public class CheckedUtil {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 接收一个可以转化成 cn.hutool.core.lang.func.Func1的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
|
||||||
*
|
|
||||||
* @param expression Lambda表达式
|
|
||||||
* @param rte 期望抛出的运行时异常
|
|
||||||
* @param <P> 运行时传入的参数类型
|
|
||||||
* @param <R> 最终返回的数据类型
|
|
||||||
* @return {@link Func1Rt}
|
|
||||||
*/
|
|
||||||
public static <P, R> Func1Rt<P, R> uncheck(Func1<P, R> 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的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
* 接收一个可以转化成 cn.hutool.core.lang.func.Func1的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
* 如此一来,代码中就不用显示的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 <P> 运行时传入的参数类型
|
|
||||||
* @return {@link VoidFuncRt}
|
|
||||||
*/
|
|
||||||
public static <P> VoidFuncRt<P> uncheck(VoidFunc<P> 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的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
* 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc的Lambda表达式,和一个可以把Exception转化成RuntimeExceptionde的表达式,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
* 如此一来,代码中就不用显示的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 <P> 运行时传入的参数类型
|
|
||||||
* @return {@link VoidFunc1Rt}
|
|
||||||
*/
|
|
||||||
public static <P> VoidFunc1Rt<P> uncheck(VoidFunc1<P> 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,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
* 接收一个可以转化成 cn.hutool.core.lang.func.VoidFunc1的Lambda表达式,和一个RuntimeException,当执行表达式抛出任何异常的时候,都会转化成运行时异常
|
||||||
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
* 如此一来,代码中就不用显示的try-catch转化成运行时异常
|
||||||
@ -418,6 +290,7 @@ public class CheckedUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface FuncRt<P, R> extends Func<P, R> {
|
public interface FuncRt<P, R> extends Func<P, R> {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
R call(P... parameters) throws RuntimeException;
|
R call(P... parameters) throws RuntimeException;
|
||||||
}
|
}
|
||||||
@ -433,6 +306,7 @@ public class CheckedUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface VoidFuncRt<P> extends VoidFunc<P> {
|
public interface VoidFuncRt<P> extends VoidFunc<P> {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
void call(P... parameters) throws RuntimeException;
|
void call(P... parameters) throws RuntimeException;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.hutool.core.net;
|
package cn.hutool.core.net;
|
||||||
|
|
||||||
import cn.hutool.core.builder.Builder;
|
import cn.hutool.core.builder.Builder;
|
||||||
import cn.hutool.core.exceptions.CheckedUtil;
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -29,6 +28,7 @@ import java.security.SecureRandom;
|
|||||||
* @since 5.5.2
|
* @since 5.5.2
|
||||||
*/
|
*/
|
||||||
public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String protocol = TLS;
|
private String protocol = TLS;
|
||||||
private KeyManager[] keyManagers;
|
private KeyManager[] keyManagers;
|
||||||
@ -104,7 +104,7 @@ public class SSLContextBuilder implements SSLProtocols, Builder<SSLContext> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SSLContext build() {
|
public SSLContext build() {
|
||||||
return CheckedUtil.uncheck(this::buildChecked, IORuntimeException::new).call();
|
return buildQuietly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@ public class SSLUtil {
|
|||||||
* @since 5.7.8
|
* @since 5.7.8
|
||||||
*/
|
*/
|
||||||
public static SSLContext createSSLContext(String protocol) throws IORuntimeException{
|
public static SSLContext createSSLContext(String protocol) throws IORuntimeException{
|
||||||
return SSLContextBuilder.create().setProtocol(protocol).buildQuietly();
|
return SSLContextBuilder.create().setProtocol(protocol).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +55,6 @@ public class SSLUtil {
|
|||||||
return SSLContextBuilder.create()
|
return SSLContextBuilder.create()
|
||||||
.setProtocol(protocol)
|
.setProtocol(protocol)
|
||||||
.setKeyManagers(keyManagers)
|
.setKeyManagers(keyManagers)
|
||||||
.setTrustManagers(trustManagers).buildQuietly();
|
.setTrustManagers(trustManagers).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ public class CheckedUtilTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Test
|
@Test
|
||||||
public void functionTest() {
|
public void functionTest() {
|
||||||
Func1<String, String> afunc = (funcParam) -> {
|
Func1<String, String> afunc = (funcParam) -> {
|
||||||
|
@ -90,6 +90,6 @@ public class SSLSocketFactoryBuilder implements SSLProtocols {
|
|||||||
* @throws KeyManagementException Key管理异常
|
* @throws KeyManagementException Key管理异常
|
||||||
*/
|
*/
|
||||||
public SSLSocketFactory build() throws NoSuchAlgorithmException, KeyManagementException {
|
public SSLSocketFactory build() throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
return this.sslContextBuilder.build().getSocketFactory();
|
return this.sslContextBuilder.buildChecked().getSocketFactory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user