Issue Details (XML | Word | Printable)

Key: NUCRDBMS-182
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Yang ZHONG
Votes: 0
Watchers: 0
Operations

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

NullPointerException in PersistentIDROF.getObjectForApplicationId

Created: 10/May/09 08:13 AM   Updated: 23/Oct/09 04:08 PM   Resolved: 14/Oct/09 08:05 PM
Component/s: Queries
Affects Version/s: 1.1.2
Fix Version/s: None

File Attachments: 1. Text File 182.patch (3 kB)

Environment: Linux, Java 5

Datastore: IBM DB2
Severity: Production


 Description  « Hide
java.lang.NullPointerException
  at org.datanucleus.store.rdbms.query.PersistentIDROF.getObjectForApplicationId(PersistentIDROF.java:377)
  at org.datanucleus.store.rdbms.query.PersistentIDROF.getObject(PersistentIDROF.java:276)
  at org.datanucleus.store.mapped.scostore.ListStoreIterator.<init>(ListStoreIterator.java:113)
  at org.datanucleus.store.rdbms.scostore.RDBMSListStoreIterator.<init>(RDBMSListStoreIterator.java:41)
  at org.datanucleus.store.rdbms.scostore.RDBMSJoinListStore.listIterator(RDBMSJoinListStore.java:170)
  at org.datanucleus.store.mapped.scostore.AbstractListStore.listIterator(AbstractListStore.java:84)
  at org.datanucleus.store.mapped.scostore.AbstractListStore.iterator(AbstractListStore.java:74)
  at org.datanucleus.sco.backed.List.loadFromStore(List.java:274)
  at org.datanucleus.sco.backed.List.toArray(List.java:712)

Sort Order: Ascending order - Click to sort in descending order
Vic Anderson added a comment - 10/May/09 08:16 AM
There seem at least 3 problems around line 377:

        boolean nullObject = true;
        for (int i=0;i<pkNumbers.length;i++)
        {
            StatementMappingIndex pkIdx = mappingDefinition.getMappingForMemberPosition(pkNumbers[i]);
            for (int j=0;j<pkIdx.getColumnPositions().length;j++) //3-1 pkIdx or pkIdx.getColumnPositions() sometimes is null
            {
                try
                {
                    Object obj = rs.getObject(pkIdx.getColumnPositions()[0]); //3-2 Should have been [j] otherwise what's the point for iteration
                    if (obj != null)
                    {
                        nullObject = false;
                        break;
                    }
                }
                catch (SQLException sqle)
                {
                    sqle.printStackTrace();
                }
                if (!nullObject) //3-3 dead code, should have been outside the inner iteration
                {
                    break;
                }
            }
        }

The attachment addresses those 3 problems.

Yang ZHONG added a comment - 10/May/09 08:23 AM
Thanks a lot to Vic for such quick fix!

Maybe "sqle.printStackTrace();" should have used logging too.

Andy Jefferson added a comment - 10/May/09 08:28 AM
Please provide a testcase that shows the issue. Why are pk positions null in your case ? That is the real problem and it has to be understood; not papering over anything downstream of a problem.

Yang ZHONG added a comment - 18/May/09 10:29 PM
NullPointerException is still there w/ DataNucleus 1.1.3. We had also tried to extract a simple Test Case, unfortunately failed due to our scenario complexity :-( PersistentIDROF looks problematic anyway, while Vic's fix won't make things worse anyway. It runs faster and makes PersistentIDROF more stable, for which thanks a lot to Vic again.

Andy Jefferson added a comment - 19/May/09 06:34 AM
I'm not committing a patch that says nothing of the context that the situation is for. You have a debugger and hence could use that. You should know what type of relation is being used at this point so could use that as a basis. About time people learned these basic facts; we don't put in checks all over the place to get efficient code. The input to the method is wrong, and it's for you to find the situation in which it is wrong.

Andy Jefferson added a comment - 14/Oct/09 08:05 PM
No way of reproducing this issue 5 months after it was raised so rejecting it. Create a testcase if you can demonstrate it