cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Rigby-Jones (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CAY-1636) NPE with commitChangesToParent() after deleting object with child and cascade delete rule
Date Tue, 01 Nov 2011 17:21:32 GMT
NPE with commitChangesToParent() after deleting object with child and cascade delete rule 
------------------------------------------------------------------------------------------

                 Key: CAY-1636
                 URL: https://issues.apache.org/jira/browse/CAY-1636
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.0.2
            Reporter: Mark Rigby-Jones


Steps to reproduce:

1) Create object A
2) Add child object B (A has a cascade delete rule for B)
3) Create a child context
4) Delete A in the child context
5) commitChangesToParent in the child context
6) NPE:
java.lang.NullPointerException
	at org.apache.cayenne.access.DataContextDeleteAction.performDelete(DataContextDeleteAction.java:59)
	at org.apache.cayenne.access.DataContext.deleteObject(DataContext.java:946)
	at org.apache.cayenne.graph.ChildDiffLoader.nodeRemoved(ChildDiffLoader.java:127)
	at org.apache.cayenne.graph.NodeDeleteOperation.apply(NodeDeleteOperation.java:37)
	at org.apache.cayenne.graph.CompoundDiff.apply(CompoundDiff.java:91)
	at org.apache.cayenne.access.ObjectStoreGraphDiff.apply(ObjectStoreGraphDiff.java:134)
	at org.apache.cayenne.access.DataContext.onContextFlush(DataContext.java:1074)
	at org.apache.cayenne.BaseContext.onSync(BaseContext.java:298)
	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1121)
	at org.apache.cayenne.access.DataContext.commitChangesToParent(DataContext.java:1051)

Analysis:

The issue appears to be that the graph diff to be committed to the parent context records
that both A and B are to be deleted, however the delete rules for A also cause B to deleted:

1) Child diff causes A to be deleted
2) A's delete rules cause B to deleted
3) Child diff causes B to be deleted, but B no longer exists

Possible fix (not tested in any way):

In ChildDiffLoader.nodeRemoved(), check if the result of findObject() is null before attempting
to delete it.

Workaround (works for me):

In the child context, delete B before deleting A.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message