Skip to content
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

Prevent NPE with empty Spring JPA specifications #773

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Prevent NPE with empty Spring JPA specifications #773

merged 1 commit into from
Oct 19, 2020

Conversation

murdos
Copy link
Contributor

@murdos murdos commented Oct 18, 2020

An empty specification can be built with Specification.where(null) and will result in a null predicate, causing a null pointer exception:

00:05:51.901 [io-executor-thread-1] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: null
java.lang.NullPointerException: null
	at org.hibernate.query.criteria.internal.predicate.BooleanExpressionPredicate.render(BooleanExpressionPredicate.java:48)
	at org.hibernate.query.criteria.internal.predicate.AbstractSimplePredicate.render(AbstractSimplePredicate.java:48)
	at org.hibernate.query.criteria.internal.QueryStructure.renderWhereClause(QueryStructure.java:351)
	at org.hibernate.query.criteria.internal.QueryStructure.render(QueryStructure.java:238)
	at org.hibernate.query.criteria.internal.CriteriaQueryImpl.interpret(CriteriaQueryImpl.java:297)
	at org.hibernate.query.criteria.internal.compile.CriteriaCompiler.compile(CriteriaCompiler.java:165)
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:742)
	at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
	at io.micronaut.data.spring.jpa.intercept.FindAllSpecificationInterceptor.intercept(FindAllSpecificationInterceptor.java:74)
	at io.micronaut.data.intercept.DataIntroductionAdvice.intercept(DataIntroductionAdvice.java:80)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)
	at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:139)
	at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)

An empty specification can be built with `Specification.where(null)`
@graemerocher
Copy link
Contributor

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants