You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Cirillo, Aaron" <am...@valassis.com> on 2016/02/18 16:15:23 UTC

Potential bug in EntityManagerImpl

Hi, I think I may have discovered a potential bug in org.apache.openjpa.persistence.EntityManagerImpl. According to the documentation on the EntityManager interface the find() method is supposed to throw an InvalidArgumentException if the second argument is null. I have observed that this is not happening.

I have looked at the documentation for both the JavaEE 6 version of EntityManager and the JavaEE 7 version. Both sets of documentation say this exception should be thrown.

http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#find(java.lang.Class, java.lang.Object)
https://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html#find-java.lang.Class-java.lang.Object-

I have created a simple test case at https://github.com/aaroncirillo/openjpa-bug to prove out the issue. Running mvn test will demonstrate the problem.

I did also look at the EntityManagerImpl code and I can see that the method returns null if the second argument is null when it should throw an IllegalArgumentException:

@SuppressWarnings("unchecked")
public <T> T find(Class<T> cls, Object oid) {
    assertNotCloseInvoked();
    if (oid == null)
        return null;
    oid = _broker.newObjectId(cls, oid);
    return (T) _broker.find(oid, true, this);
}



--
Aaron Cirillo
Senior Systems Engineer, BTS
Valassis / BTS
One Targeting Centre
Windsor, CT, 06095
Tel: 860-298-5779
Cell: 860-682-0651
amcirillo@valassis.com<ma...@valassis.com>
www.valassis.com<http://www.valassis.com>

Creating the future of intelligent media delivery to drive your greatest success
___________________________________________________________________________________

This message may include proprietary or protected information. If you are not the intended recipient, please notify me, delete this message and do not further communicate the information contained herein without my express consent.