[ 
https://issues.apache.org/jira/browse/OPENJPA-1301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12755319#action_12755319
 ] 

Tim McConnell commented on OPENJPA-1301:
----------------------------------------

There are a couple problems with the implementation of the hashcode() and 
equals() methods in EntityManagerFactoryImpl. First, neither checks whether 
_factory is null, which can and does cause NullPointException(s). Second, it's 
not usually good form to use instanceof in the equals() method in a class that 
is not "final" as it can easily violate the symmetry requirement of 
equivalence. 

No testcase is provided in this case as it can be easily reproduced in while 
debugging in Eclipse, interrogating an instance of EntityManagerFactoryImpl 
prior to the instantiation of _factory, which will invoke the toString() 
method, which will invoke the hashcode() method, which will cause a 
NullPointerException. 

A cursory check has turned up some other classes with similar implementation 
problems that I'll correct with separate patches as I do not feel comfortable 
doing it all in a single mass update. 

> EntityManagerFactoryImpl
> ------------------------
>
>                 Key: OPENJPA-1301
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1301
>             Project: OpenJPA
>          Issue Type: Sub-task
>            Reporter: Tim McConnell
>            Assignee: Tim McConnell
>            Priority: Minor
>         Attachments: OPENJPA-1301.patch
>
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to