Skip to content

NPE in AnnotationAwareOrderComparator.getPriority [SPR-16508] #21051

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits c9d08bf

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions