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

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:
at org.datanucleus.ObjectManagerImpl.findObjects(
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectsById(
at org.datanucleus.api.jdo.JDOPersistenceManager.getObjectsById(
at org.datanucleus.test.Main.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.codehaus.mojo.exec.ExecJavaMojo$

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/ 2012-02-02 16:40:14.000000000 +0000
+++ org/datanucleus/ 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);

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 02/Mar/12 09:16 AM
SVN trunk and branches/3.0 fix this