-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当通过 @AutoOperate#on
从返回值中提取待填充数据时,会偶发空指针异常
#299
Comments
同样的场景还会偶发异常:
|
第一个问题看起来是由于 ReflectUtils#getDeclaredFields 方法入参为 null 引起的,不过光靠这个堆栈很难排查出为什么一条路传下来冒出来了一个 null。第二个问题目前还没有什么头绪,感觉可能跟 JDK 版本有关系。 这两个问题我本地都没有复现出来,能否把涉及到的相关代码发上来呢?包括触发填充的方法和它返回的类(即被 @AutoOperate 注解的方法),被填充的类以及它的父类和接口(如果有的话),如果有可运行的实例代码就更好了。 |
目前能确认的是, 具体来说,当进行反射的时候,都会调用 public static void traverseTypeHierarchy(Class<?> beanType, Consumer<Class<?>> consumer) {
Set<Class<?>> accessed = new HashSet<>();
Deque<Class<?>> typeQueue = new LinkedList<>();
typeQueue.add(beanType);
while (!typeQueue.isEmpty()) {
Class<?> type = typeQueue.removeFirst();
accessed.add(type);
// do something for current type
consumer.accept(type);
// then find superclass and interfaces
Set<Class<?>> declaredSuperClassWithInterface = getDeclaredSuperClassWithInterface(type); // 获取父类与接口
declaredSuperClassWithInterface.remove(Object.class);
declaredSuperClassWithInterface.removeAll(accessed);
CollectionUtils.addAll(typeQueue, declaredSuperClassWithInterface);
}
} 问题在于, public static Set<Class<?>> getDeclaredSuperClassWithInterface(Class<?> type) {
return CollectionUtils.computeIfAbsent(DECLARED_SUPER_CLASS_WITH_INTERFACE, type, k -> {
Set<Class<?>> result = new LinkedHashSet<>();
Class<?> superClass = type.getSuperclass();
if (superClass != null) {
result.add(superClass);
}
result.addAll(Arrays.asList(type.getInterfaces()));
return result;
});
} 而在 不过,上面的空指针目前仍然不能确认是什么原因造成的,只能根据堆栈初步判断是在通过 这周内会发布 2.8.1 先修复 |
在新增数据之后,立即调用查询方法,间隔时间比较端,在毫秒级别,就会有一定概率出现这个异常
The text was updated successfully, but these errors were encountered: