[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5195?page=c...
]
Gail Badner resolved HHH-5195.
------------------------------
Resolution: Fixed
Fixed in trunk and Branch_3_5.
Jared, thanks for the patches.
It turns out that enabled filters are not propagated to a new session by
NonFlushedChanges, so I added
ConnectionManagementTestCase.testEnabledFilterSerialization() to reproduce this, since
session serialization tests are in ConnectionManagementTestCase.
Also, I didn't want to make LoadQueryInfluencers.getEnabledFilters(boolean
validateFilters) public, so I added a method to get the enabled filter names to be able to
get each enabled filters via LoadQueryInfluencers.getEnabledFilter(String filterName),
which does not do the validation.
After FilterImpl.afterDeserialize(SessionFactoryImpl factory) sets the definition, the
Filter is validated.
FilterImpl.validate() throws NullPointerExeption on deserialization
-------------------------------------------------------------------
Key: HHH-5195
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5195
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1
Environment: hibernate-distribution-3.5.1-Final-dist
Reporter: Savochkin Alexander
Assignee: Gail Badner
Fix For: 3.5.3, 3.6
Attachments: HHH-5195-testsuite.diff, HHH-5195-testsuite.diff, HHH-5195.diff
After deserialization NPE is thrown at this line
FilterImpl
{code}
line:164
Iterator itr = definition.getParameterNames().iterator();
{code}
the last lines from stack trace are:
{code}
java.lang.NullPointerException
at org.hibernate.impl.FilterImpl.validate(FilterImpl.java:164)
at
org.hibernate.engine.LoadQueryInfluencers.getEnabledFilters(LoadQueryInfluencers.java:109)
at org.hibernate.impl.SessionImpl.readObject(SessionImpl.java:2144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:986)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1865)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1345)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:364)
{code}
Looking at SessionImpl class we see:
{code}
line 2143:
Iterator iter = loadQueryInfluencers.getEnabledFilters().values().iterator();
while ( iter.hasNext() ) {
( ( FilterImpl ) iter.next() ).afterDeserialize( factory );
}
{code}
LoadQueryInfluencers:
{code}
line:105
Iterator itr = enabledFilters.values().iterator();
while ( itr.hasNext() ) {
final Filter filter = ( Filter ) itr.next();
filter.validate();
}
{code}
So, afterDeserialization() on enabled filters method is invoked AFTER getEnabledFilters()
method is.
It seems to be the reason why the private TRANSIENT field "definition" of every
filter is null at the moment of filter validation!
"definition" field is supposed to be initialized only after validate() is
called.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira