-
Notifications
You must be signed in to change notification settings - Fork 174
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
NPE in QueryBasedValueHolder due to #2181 #2317
Comments
Hello, Experiencing the same issue, It looks like it is indeed introduced by #2181 and the move from
I see other issues also pointing #2181 as potential root cause (like #2219). Thank you in advance. |
First release candidate of EclipseLink 4.0.5 (4.0.5-RC1) is available. |
Great 👍 |
Fixed in 4.0 branch, please reopen issue or leave message there is issue remains. |
Description
When populating the second-level cache, eclipselink 4.0.4 sometimes throws
Exception in thread "Thread-2" java.lang.NullPointerException: Cannot invoke "org.eclipse.persistence.queries.ReadQuery.isReadObjectQuery()" because "this.query" is null
at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.getValue(QueryBasedValueHolder.java:102)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:176)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:252)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:109)
at concurrency.Employee._persistence_get_department(Employee.java)
at concurrency.Employee.getDepartment(Employee.java:42)
at concurrency.Main.lambda$main$0(Main.java:23)
at java.base/java.lang.Thread.run(Thread.java:840)
There is no exception with version 4.0.3. The change that added the bug is #2181.
To Reproduce
This results in the exception.
Explanation
The problem is UnitOfWorkValueHolder uses its "wrappedValueHolderLock" to lock its wrapped queryBasedValueHolder instead of using the queryBasedValueHolder's lock.
I've provided a fix (an ugly one) to show this is the issue. You can use it by removing the "_2" at the end of the provided files DatabaseValueHolder_2 and UnitOfWorkValueHolder_2.
Potential additional issue
The value holders are clonable and their clone method only makes a shallow-copy of the fields. So, after a clone, two cloned value holders have the same lock.
On the other hand, "synchronized(this)" in 4.0.3 synchronizes on two different objects (the two cloned objects). I didn't investigate further though.
The text was updated successfully, but these errors were encountered: