mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-05 21:28:00 +08:00
fix
This commit is contained in:
commit
05d13de588
@ -14,7 +14,12 @@
|
|||||||
* 【cron 】 修复Cron表达式range解析错误问题(issue#I82CSH@Gitee)
|
* 【cron 】 修复Cron表达式range解析错误问题(issue#I82CSH@Gitee)
|
||||||
* 【core 】 修复VersionComparator在极端数据排序时候违反了自反性问题(issue#I81N3H@Gitee)
|
* 【core 】 修复VersionComparator在极端数据排序时候违反了自反性问题(issue#I81N3H@Gitee)
|
||||||
* 【json 】 修复JSONStrFormatter:format函数对于转义符号处理逻辑错误问题(issue#I84V6I@Gitee)
|
* 【json 】 修复JSONStrFormatter:format函数对于转义符号处理逻辑错误问题(issue#I84V6I@Gitee)
|
||||||
|
<<<<<<< HEAD
|
||||||
* 【core 】 修复特定情况下BiMap覆盖Value后,仍能通过旧Value查询到Key问题(issue#I88R5M@Gitee)
|
* 【core 】 修复特定情况下BiMap覆盖Value后,仍能通过旧Value查询到Key问题(issue#I88R5M@Gitee)
|
||||||
|
=======
|
||||||
|
* 【core 】 修复aop的afterException无法生效问题(issue#3329@Github)
|
||||||
|
* 【core 】 修复TypeUtil.getClass方法强转报错问题(pr#1092@Github)
|
||||||
|
>>>>>>> fd9e1efa2860ded5cf2d1be5954fd87a2a5830fe
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.22(2023-09-13)
|
# 5.8.22(2023-09-13)
|
||||||
|
@ -43,10 +43,14 @@ public class CglibInterceptor implements MethodInterceptor, Serializable {
|
|||||||
try {
|
try {
|
||||||
// result = proxy.invokeSuper(obj, args);
|
// result = proxy.invokeSuper(obj, args);
|
||||||
result = proxy.invoke(target, args);
|
result = proxy.invoke(target, args);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (final Throwable e) {
|
||||||
|
Throwable throwable = e;
|
||||||
|
if(throwable instanceof InvocationTargetException){
|
||||||
|
throwable = ((InvocationTargetException) throwable).getTargetException();
|
||||||
|
}
|
||||||
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
||||||
if (aspect.afterException(target, method, args, e.getTargetException())) {
|
if (aspect.afterException(target, method, args, throwable)) {
|
||||||
throw e;
|
throw throwable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,14 @@ public class SpringCglibInterceptor implements MethodInterceptor, Serializable {
|
|||||||
try {
|
try {
|
||||||
// result = proxy.invokeSuper(obj, args);
|
// result = proxy.invokeSuper(obj, args);
|
||||||
result = proxy.invoke(target, args);
|
result = proxy.invoke(target, args);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (Throwable e) {
|
||||||
|
Throwable throwable = e;
|
||||||
|
if(throwable instanceof InvocationTargetException){
|
||||||
|
throwable = ((InvocationTargetException) throwable).getTargetException();
|
||||||
|
}
|
||||||
|
|
||||||
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
// 异常回调(只捕获业务代码导致的异常,而非反射导致的异常)
|
||||||
if (aspect.afterException(target, method, args, e.getTargetException())) {
|
if (aspect.afterException(target, method, args, throwable)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,10 @@ public class TypeUtil {
|
|||||||
} else if (type instanceof ParameterizedType) {
|
} else if (type instanceof ParameterizedType) {
|
||||||
return (Class<?>) ((ParameterizedType) type).getRawType();
|
return (Class<?>) ((ParameterizedType) type).getRawType();
|
||||||
} else if (type instanceof TypeVariable) {
|
} else if (type instanceof TypeVariable) {
|
||||||
return (Class<?>) ((TypeVariable<?>) type).getBounds()[0];
|
Type[] bounds = ((TypeVariable<?>) type).getBounds();
|
||||||
|
if (bounds.length == 1) {
|
||||||
|
return getClass(bounds[0]);
|
||||||
|
}
|
||||||
} else if (type instanceof WildcardType) {
|
} else if (type instanceof WildcardType) {
|
||||||
final Type[] upperBounds = ((WildcardType) type).getUpperBounds();
|
final Type[] upperBounds = ((WildcardType) type).getUpperBounds();
|
||||||
if (upperBounds.length == 1) {
|
if (upperBounds.length == 1) {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package cn.hutool.core.util;
|
package cn.hutool.core.util;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TypeUtilTest {
|
public class TypeUtilTest {
|
||||||
|
|
||||||
@ -31,6 +30,19 @@ public class TypeUtilTest {
|
|||||||
Assert.assertEquals(Integer.class, returnType);
|
Assert.assertEquals(Integer.class, returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getClasses() {
|
||||||
|
Method method = ReflectUtil.getMethod(Parent.class, "getLevel");
|
||||||
|
Type returnType = TypeUtil.getReturnType(method);
|
||||||
|
Class clazz = TypeUtil.getClass(returnType);
|
||||||
|
Assert.assertEquals(Level1.class, clazz);
|
||||||
|
|
||||||
|
method = ReflectUtil.getMethod(Level1.class, "getId");
|
||||||
|
returnType = TypeUtil.getReturnType(method);
|
||||||
|
clazz = TypeUtil.getClass(returnType);
|
||||||
|
Assert.assertEquals(Object.class, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
public static class TestClass {
|
public static class TestClass {
|
||||||
public List<String> getList() {
|
public List<String> getList() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -39,6 +51,7 @@ public class TypeUtilTest {
|
|||||||
public Integer intTest(Integer integer) {
|
public Integer intTest(Integer integer) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -61,8 +74,7 @@ public class TypeUtilTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getActualTypesTest() {
|
public void getActualTypesTest() {
|
||||||
// 测试多层级泛型参数是否能获取成功
|
// 测试多层级泛型参数是否能获取成功
|
||||||
Type idType = TypeUtil.getActualType(Level3.class,
|
Type idType = TypeUtil.getActualType(Level3.class, ReflectUtil.getField(Level3.class, "id"));
|
||||||
ReflectUtil.getField(Level3.class, "id"));
|
|
||||||
|
|
||||||
Assert.assertEquals(Long.class, idType);
|
Assert.assertEquals(Long.class, idType);
|
||||||
}
|
}
|
||||||
@ -80,4 +92,9 @@ public class TypeUtilTest {
|
|||||||
private T id;
|
private T id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Parent<T extends Level1<B>, B extends Long> {
|
||||||
|
private T level;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user