You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2012/10/21 11:30:11 UTC

[jira] [Created] (CAY-1749) NPE on simple nested context commit

Andrus Adamchik created CAY-1749:
------------------------------------

             Summary: NPE on simple nested context commit
                 Key: CAY-1749
                 URL: https://issues.apache.org/jira/browse/CAY-1749
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.1B2
            Reporter: Andrus Adamchik
            Assignee: Andrus Adamchik


An odd problem happens when building on Jenkins. E.g. this build (Java 7, HSQLDB) :

https://builds.apache.org/job/Cayenne-trunk/cayenneTestConnection=HSQLDB,jdk=JDK%201.7%20%28latest%29,label=Ubuntu/781/

results in the following exception:
-------------------------------------------------------------------------------
Test set: org.apache.cayenne.access.NestedDataContextWriteTest
-------------------------------------------------------------------------------
Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.151 sec <<< FAILURE!
testAddRemove(org.apache.cayenne.access.NestedDataContextWriteTest)  Time elapsed: 0.012 sec  <<< ERROR!
java.lang.NullPointerException
	at org.apache.commons.collections.map.AbstractReferenceMap$ReferenceEntry.getValue(AbstractReferenceMap.java:597)
	at org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:234)
	at org.apache.cayenne.access.ObjectStore.postprocessAfterCommit(ObjectStore.java:417)
	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:771)
	at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:697)
	at org.apache.cayenne.access.NestedDataContextWriteTest.testAddRemove(NestedDataContextWriteTest.java:632)


The code is as vanilla and single threaded as it gets:

        DataContext context = createDataContext();
        ObjectContext child = runtime.getContext(context);

        Artist a = child.newObject(Artist.class);
        a.setArtistName("X");
        child.commitChanges(); // this is line 632 that causes exception

It appears that ObjectStore.objectMap somehow gets corrupted... Sure enough it is only reproducible on Jenkins, and never - locally.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAY-1749) NPE on simple nested context commit

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13480952#comment-13480952 ] 

Andrus Adamchik commented on CAY-1749:
--------------------------------------

The cause is missing synchronization in nested ObjectContext handler of grandparent events. (DataContextMergeHandler.graphFlushed(..)). I think this was always an issue, however the race condition became more prominent once CAY-1737 was implemented. 

TODO: Actually committing object context should not receive grandparent flush event which it indirectly originated. Our event displatch filtering is inadequate to detect commit author across the chain of nested context commits. Need to improve that in 3.2 (maybe via a transaction object that has a chanin of committed contexts in it?)


                
> NPE on simple nested context commit
> -----------------------------------
>
>                 Key: CAY-1749
>                 URL: https://issues.apache.org/jira/browse/CAY-1749
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B2
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>
> An odd problem happens when building on Jenkins. E.g. this build (Java 7, HSQLDB) :
> https://builds.apache.org/job/Cayenne-trunk/cayenneTestConnection=HSQLDB,jdk=JDK%201.7%20%28latest%29,label=Ubuntu/781/
> results in the following exception:
> -------------------------------------------------------------------------------
> Test set: org.apache.cayenne.access.NestedDataContextWriteTest
> -------------------------------------------------------------------------------
> Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.151 sec <<< FAILURE!
> testAddRemove(org.apache.cayenne.access.NestedDataContextWriteTest)  Time elapsed: 0.012 sec  <<< ERROR!
> java.lang.NullPointerException
> 	at org.apache.commons.collections.map.AbstractReferenceMap$ReferenceEntry.getValue(AbstractReferenceMap.java:597)
> 	at org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:234)
> 	at org.apache.cayenne.access.ObjectStore.postprocessAfterCommit(ObjectStore.java:417)
> 	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:771)
> 	at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:697)
> 	at org.apache.cayenne.access.NestedDataContextWriteTest.testAddRemove(NestedDataContextWriteTest.java:632)
> The code is as vanilla and single threaded as it gets:
>         DataContext context = createDataContext();
>         ObjectContext child = runtime.getContext(context);
>         Artist a = child.newObject(Artist.class);
>         a.setArtistName("X");
>         child.commitChanges(); // this is line 632 that causes exception
> It appears that ObjectStore.objectMap somehow gets corrupted... Sure enough it is only reproducible on Jenkins, and never - locally.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAY-1749) NPE on simple nested context commit

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13480940#comment-13480940 ] 

Andrus Adamchik commented on CAY-1749:
--------------------------------------

The offending event seems to be coming from parent DataContext.flushToParent(..), at the end of the method:

           // this event is caught by child DataContexts to update temporary
            // ObjectIds with permanent
            if (!diff.isNoop()) {
                fireDataChannelCommitted(getChannel(), diff);
            }

                
> NPE on simple nested context commit
> -----------------------------------
>
>                 Key: CAY-1749
>                 URL: https://issues.apache.org/jira/browse/CAY-1749
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B2
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>
> An odd problem happens when building on Jenkins. E.g. this build (Java 7, HSQLDB) :
> https://builds.apache.org/job/Cayenne-trunk/cayenneTestConnection=HSQLDB,jdk=JDK%201.7%20%28latest%29,label=Ubuntu/781/
> results in the following exception:
> -------------------------------------------------------------------------------
> Test set: org.apache.cayenne.access.NestedDataContextWriteTest
> -------------------------------------------------------------------------------
> Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.151 sec <<< FAILURE!
> testAddRemove(org.apache.cayenne.access.NestedDataContextWriteTest)  Time elapsed: 0.012 sec  <<< ERROR!
> java.lang.NullPointerException
> 	at org.apache.commons.collections.map.AbstractReferenceMap$ReferenceEntry.getValue(AbstractReferenceMap.java:597)
> 	at org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:234)
> 	at org.apache.cayenne.access.ObjectStore.postprocessAfterCommit(ObjectStore.java:417)
> 	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:771)
> 	at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:697)
> 	at org.apache.cayenne.access.NestedDataContextWriteTest.testAddRemove(NestedDataContextWriteTest.java:632)
> The code is as vanilla and single threaded as it gets:
>         DataContext context = createDataContext();
>         ObjectContext child = runtime.getContext(context);
>         Artist a = child.newObject(Artist.class);
>         a.setArtistName("X");
>         child.commitChanges(); // this is line 632 that causes exception
> It appears that ObjectStore.objectMap somehow gets corrupted... Sure enough it is only reproducible on Jenkins, and never - locally.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CAY-1749) NPE on simple nested context commit

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAY-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13480934#comment-13480934 ] 

Andrus Adamchik commented on CAY-1749:
--------------------------------------

Found a description of a similar NPE https://issues.apache.org/jira/browse/JCR-1271 ... looks like a concurrency issue (parent context event arrives while child is still processing commit state?)
                
> NPE on simple nested context commit
> -----------------------------------
>
>                 Key: CAY-1749
>                 URL: https://issues.apache.org/jira/browse/CAY-1749
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B2
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>
> An odd problem happens when building on Jenkins. E.g. this build (Java 7, HSQLDB) :
> https://builds.apache.org/job/Cayenne-trunk/cayenneTestConnection=HSQLDB,jdk=JDK%201.7%20%28latest%29,label=Ubuntu/781/
> results in the following exception:
> -------------------------------------------------------------------------------
> Test set: org.apache.cayenne.access.NestedDataContextWriteTest
> -------------------------------------------------------------------------------
> Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.151 sec <<< FAILURE!
> testAddRemove(org.apache.cayenne.access.NestedDataContextWriteTest)  Time elapsed: 0.012 sec  <<< ERROR!
> java.lang.NullPointerException
> 	at org.apache.commons.collections.map.AbstractReferenceMap$ReferenceEntry.getValue(AbstractReferenceMap.java:597)
> 	at org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:234)
> 	at org.apache.cayenne.access.ObjectStore.postprocessAfterCommit(ObjectStore.java:417)
> 	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:771)
> 	at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:697)
> 	at org.apache.cayenne.access.NestedDataContextWriteTest.testAddRemove(NestedDataContextWriteTest.java:632)
> The code is as vanilla and single threaded as it gets:
>         DataContext context = createDataContext();
>         ObjectContext child = runtime.getContext(context);
>         Artist a = child.newObject(Artist.class);
>         a.setArtistName("X");
>         child.commitChanges(); // this is line 632 that causes exception
> It appears that ObjectStore.objectMap somehow gets corrupted... Sure enough it is only reproducible on Jenkins, and never - locally.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Closed] (CAY-1749) NPE on simple nested context commit

Posted by "Andrus Adamchik (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAY-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik closed CAY-1749.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 3.2M1
                   3.1B2
    
> NPE on simple nested context commit
> -----------------------------------
>
>                 Key: CAY-1749
>                 URL: https://issues.apache.org/jira/browse/CAY-1749
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.1B2
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 3.1B2, 3.2M1
>
>
> An odd problem happens when building on Jenkins. E.g. this build (Java 7, HSQLDB) :
> https://builds.apache.org/job/Cayenne-trunk/cayenneTestConnection=HSQLDB,jdk=JDK%201.7%20%28latest%29,label=Ubuntu/781/
> results in the following exception:
> -------------------------------------------------------------------------------
> Test set: org.apache.cayenne.access.NestedDataContextWriteTest
> -------------------------------------------------------------------------------
> Tests run: 11, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.151 sec <<< FAILURE!
> testAddRemove(org.apache.cayenne.access.NestedDataContextWriteTest)  Time elapsed: 0.012 sec  <<< ERROR!
> java.lang.NullPointerException
> 	at org.apache.commons.collections.map.AbstractReferenceMap$ReferenceEntry.getValue(AbstractReferenceMap.java:597)
> 	at org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:234)
> 	at org.apache.cayenne.access.ObjectStore.postprocessAfterCommit(ObjectStore.java:417)
> 	at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:771)
> 	at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:697)
> 	at org.apache.cayenne.access.NestedDataContextWriteTest.testAddRemove(NestedDataContextWriteTest.java:632)
> The code is as vanilla and single threaded as it gets:
>         DataContext context = createDataContext();
>         ObjectContext child = runtime.getContext(context);
>         Artist a = child.newObject(Artist.class);
>         a.setArtistName("X");
>         child.commitChanges(); // this is line 632 that causes exception
> It appears that ObjectStore.objectMap somehow gets corrupted... Sure enough it is only reproducible on Jenkins, and never - locally.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira