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

Restore lenient null return value for ConditionContext.getBeanFactory() [SPR-16866] #21405

Closed
spring-issuemaster opened this Issue May 23, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented May 23, 2018

Andy Wilkinson opened SPR-16866 and commented

Following the nullability changes in 5.0, three methods on ConditionContext may no longer return null, but may now throw an IlegalStateException instead. Those methods are:

  • getRegistry()
  • getBeanFactory()
  • getClassLoader()

It would be useful if their javadoc documented that an IllegalStateException may now be thrown.


Affects: 5.0.6

Reference URL: spring-projects/spring-boot#13226

Referenced from: commits 50d6d90, 46a89d9

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator

spring-issuemaster commented May 28, 2018

Juergen Hoeller commented

It turns out that the deduced getBeanFactory() and getClassLoader() accessors should indeed be @Nullable since the registry may not be downcastable to the former whereas the resource loader's ClassLoader may actually be null (which is why null is also accepted as an argument to the common ClassUtils.forName method).

getRegistry() is arguably a special case since it is usually non-null, except for plain ClassPathScanningCandidateComponentProvider usage. I've retained the IllegalStateException there for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment