[JIRA] (HHH-16788) CaseSearchedExpression whenFragments contains null value
by Lars Benedetto (JIRA)
Lars Benedetto ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5bb1d56... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODRjNjY1Mzgz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16788?atlOrigin=eyJpIjoiODRjNj... ) HHH-16788 ( https://hibernate.atlassian.net/browse/HHH-16788?atlOrigin=eyJpIjoiODRjNj... ) CaseSearchedExpression whenFragments contains null value ( https://hibernate.atlassian.net/browse/HHH-16788?atlOrigin=eyJpIjoiODRjNj... )
Change By: Lars Benedetto ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5bb1d56... )
{noformat}Java.lang.NullPointerException: Cannot invoke "org.hibernate.sql.ast.tree.expression.CaseSearchedExpression$WhenFragment.getPredicate()" because "whenFragment" is null
at org.hibernate.sql.ast.spi.AbstractSqlAstTranslator.visitAnsiCaseSearchedExpression(AbstractSqlAstTranslator.java:6431){noformat}
We recently updated to 6.2.4 from 5.x and started occasionally seeing large spikes of errors with this stacktrace. One pod, out of dozens, will suddenly start getting this error for about 10% of findById queries on a specific Repository and continue until it is manually killed. We’ve been unable to figure out how to reproduce the issue, but it seems to correlate with high system load.
{noformat} @Query("SELECT p FROM TblEntity e WHERE e.id = :id")
Optional<TblEntity> findById(@Param("id") long id);{noformat}
I had a look at which whenFragments exist when the query succeeds, and narrowed the issue down to a join column:
{noformat}@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "payment_id")
private List<TblPaymentChange> paymentChanges;{noformat}
Where TblPaymentChange has
{noformat}@OneToOne(optional = true, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumns({
@JoinColumn(name = "payment_id", referencedColumnName = "payment_id",
nullable = true),
@JoinColumn(name = "sort_index", referencedColumnName = "sort_index",
nullable = true)
})
private TblPaymentChangeDetail changeDetails;{noformat}
This the line in the code where the NPE occurs
{noformat} for ( CaseSearchedExpression.WhenFragment whenFragment : caseSearchedExpression.getWhenFragments() ) {
...
whenFragment.getPredicate().accept( this ); // <-- NPE, whenFragment is null somehow
...
}{noformat}
I’ve done my best to look through the hibernate code and I can’t figure out a single way that a null value could make its way into that list of when fragments. As far as I can tell, the when fragments are always instantiated and then immediately passed into the add() function, never stored in an intermediate variable that could become null. The only thing I can think of is that the when fragments are getting garbage collected.
( https://hibernate.atlassian.net/browse/HHH-16788#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16788#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:956085d )
1 year, 3 months