Closed
Description
Mario Hochreiter opened SPR-16508 and commented
The null check in spring 5 was removed. In my project a bean is returning null. It is marked as Nullable, nevertheless the container startup fails due to a NPE at line 109 in AnnotationAwareOrderComparator of 5.0.3.
Code in 4.3.12:
public Integer getPriority(Object obj) {
Integer priority = null;
if (obj instanceof Class) {
priority = OrderUtils.getPriority((Class<?>) obj);
}
else if (obj != null) {
priority = OrderUtils.getPriority(obj.getClass());
if (priority == null && obj instanceof DecoratingProxy) {
priority = OrderUtils.getOrder(((DecoratingProxy) obj).getDecoratedClass());
}
}
return priority;
}
Now in 5.0.3:
public Integer getPriority(Object obj) {
if (obj instanceof Class) {
return OrderUtils.getPriority((Class<?>) obj);
}
Integer priority = OrderUtils.getPriority(obj.getClass());
if (priority == null && obj instanceof DecoratingProxy) {
priority = OrderUtils.getOrder(((DecoratingProxy) obj).getDecoratedClass());
}
return priority;
}
Affects: 5.0.3
Issue Links:
- NullPointerException in AnnotationAwareOrderComparator#getPriority [SPR-16583] #21125 NullPointerException in AnnotationAwareOrderComparator#getPriority ("is duplicated by")
- AnnotationAwareOrderComparator doesn't handle null values anymore [SPR-15823] #20378 AnnotationAwareOrderComparator doesn't handle null values anymore
Referenced from: commits c9d08bf