[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-5195) FilterImpl.validate() throws NullPointerExeption at line 164
Jared Stehler (JIRA)
noreply at atlassian.com
Thu May 13 17:23:24 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jared Stehler updated HHH-5195:
-------------------------------
Attachment: HHH-5195.diff
I am also running into this issue. I am using Spring webflow, with a org.springframework.webflow.persistence.HibernateFlowExecutionListener which serializes a hibernate session into the flow scope. My session factory enables a filter upon each openSession() or getCurrentSession() call. The object deserialization logic is flawed in SessionImpl::readObject(..), in that it makes a call to loadQueryInfluencers.getEnabledFilters() in order to deserialize each one, while that method attempts to validate that each filter has a definition before returning them (a chicken and egg kind of problem, exactly as the original poster of this issue described).
I am attaching a patch which adds a validate option to LoadQueryInfluencers.getEnabledFilters(), and updated SessionImpl.readObject to use that new method to get the list of filters without having them validate themselves.
> FilterImpl.validate() throws NullPointerExeption at line 164
> ------------------------------------------------------------
>
> 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
> Attachments: 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list