[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2846) Earlier NullPointerException in AbstractPersistentCollection
Elliotte Rusty Harold (JIRA)
noreply at atlassian.com
Mon Sep 17 10:16:14 EDT 2007
Earlier NullPointerException in AbstractPersistentCollection
------------------------------------------------------------
Key: HHH-2846
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2846
Project: Hibernate3
Issue Type: Improvement
Components: core
Environment: 3.2.5+
Reporter: Elliotte Rusty Harold
Priority: Minor
I'm currently tracking down a bug in either my code or Hibernate (don't know which yet) that seems to relate to null sessions in org.hibernate.collection.AbstractPersistentCollection. It would be helpful if this class threw the exception earlier when the session is first set to null rather than at some later point. In particular, I would like to see a null check in the constructor and setCurrentSession. Something like this:
public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
if (session==this.session) {
return false;
}
else if (session == null) {
throw new NullPointerException("null session");
}
...
Possibly it should throw a HibernateException instead of NullPointerException, but I'd definitely like the exception to come up sooner rather than later.
Browsing the code, I don't think a null session is ever legal here.
The one place there is a check is in forceInitialization which is where my code is throwing its exception:
public final void forceInitialization() throws HibernateException {
if (!initialized) {
if (initializing) {
throw new AssertionFailure("force initialize loading collection");
}
if (session==null) {
throw new HibernateException("collection is not associated with any session");
}
However it seems that at this point the real bug has already happened. This is just a symptom.
--
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