DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-814
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Balázs Lécz
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

NPE in ObjectManagerImpl.findObjects() if Level 2 cache is not configured

Created: 01/Mar/12 12:28 AM   Updated: 30/Mar/12 09:25 AM   Resolved: 02/Mar/12 09:16 AM
Component/s: None
Affects Version/s: 3.0.8
Fix Version/s: 3.0.10, 3.1.0.m1


 Description  « Hide
With version 3.0.8:
java.lang.NullPointerException
at org.datanucleus.ObjectManagerImpl.findObjects(ObjectManagerImpl.java:2938)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectsById(JDOPersistenceManager.java:1825)
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectsById(JDOPersistenceManager.java:1803)
at org.datanucleus.test.Main.main(Main.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:290)
at java.lang.Thread.run(Thread.java:679)

Root cause: ObjectManagerImpl.getObjectsFromLevel2Cache() returns null by default, instead of an empty Map.
Returning an empty map would fix the issue, but it would be better to forgo calling getObjectsFromLevel2Cache() when context.hasLevel2Cache() is false:

--- org/datanucleus/ObjectManagerImpl.java 2012-02-02 16:40:14.000000000 +0000
+++ org/datanucleus/ObjectManagerImpl.java 2012-02-29 23:26:15.437252863 +0000
@@ -2931,7 +2931,7 @@
             }
         }
 
- if (!idsToFind.isEmpty())
+ if (!idsToFind.isEmpty() && context.hasLevel2Cache())
         {
             // Check the L2 cache for those not found
             Map pcsById = getObjectsFromLevel2Cache(idsToFind);


Andy Jefferson added a comment - 02/Mar/12 09:16 AM
SVN trunk and branches/3.0 fix this

Andy Jefferson made changes - 02/Mar/12 09:16 AM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.0.10 [ 11501 ]
Fix Version/s 3.1.0.m1 [ 11450 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 30/Mar/12 09:25 AM
Status Resolved [ 5 ] Closed [ 6 ]