You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Amaury SECHET (JIRA)" <ji...@apache.org> on 2011/06/27 10:17:47 UTC

[jira] [Created] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
----------------------------------------------------------------------------------------

                 Key: CAY-1583
                 URL: https://issues.apache.org/jira/browse/CAY-1583
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.0.1
         Environment: sun Java  jre
            Reporter: Amaury SECHET


context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore

This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.

However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
		// use a setter to properly initialize EntityResolver
		setChannel(channel);
		
form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET commented on CAY-1583:
------------------------------------

After some testing, this solution looks good too. I'll go for it.

> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET updated CAY-1583:
-------------------------------

    Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.  (was: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux.)

> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Dzmitry Kazimirchyk commented on CAY-1583:
------------------------------------------

Thanks for the clarification. Yes, I think it happens because of DataContextMergehandler begins to listen to parent channel events before context's ObjectStore is set. And I suppose setting ObjectStore before setting parent channel is the solution for this.
So I've committed this:

Index: framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
===================================================================
--- framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(revision 1147116)
+++ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(working copy)
@@ -199,14 +199,17 @@
      * @since 1.2
      */
     public DataContext(DataChannel channel, ObjectStore objectStore) {
-        // use a setter to properly initialize EntityResolver
-        setChannel(channel);
 
         // inject self as parent context
         if (objectStore != null) {
             this.objectStore = objectStore;
             objectStore.setContext(this);
+        }
+        
+        // use a setter to properly initialize EntityResolver
+        setChannel(channel);
 
+        if (objectStore != null) {
             DataDomain domain = getParentDataDomain();
             this.usingSharedSnaphsotCache = domain != null
                     && objectStore.getDataRowCache() == domain.getSharedSnapshotCache();

If it solves the problem I think we can close this issue.


> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET commented on CAY-1583:
------------------------------------

I'll run some tests and let you know. I think this solve the problem but nothing could replace a test !

> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Dzmitry Kazimirchyk closed CAY-1583.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.1M3
                   3.0.3
         Assignee: Dzmitry Kazimirchyk

> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>            Assignee: Dzmitry Kazimirchyk
>             Fix For: 3.0.3, 3.1M3
>
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET updated CAY-1583:
-------------------------------

    Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux.  (was: sun Java  jre)

> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET commented on CAY-1583:
------------------------------------

Yes you are right, I made a mistake and meant DataContextMergeHandler. Anyway, no, the application doesn't use serialization. This is a quite simple application that process a huge amount of data to put it in a database. The only thing is that tha amount of data is huge and everything is multithreaded, causing this race condition.

Index: branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
===================================================================
--- branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(révision 1144473)
+++ branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(copie de travail)
@@ -199,9 +199,6 @@
      * @since 1.2
      */
     public DataContext(DataChannel channel, ObjectStore objectStore) {
-        // use a setter to properly initialize EntityResolver
-        setChannel(channel);
-
         // inject self as parent context
         if (objectStore != null) {
             this.objectStore = objectStore;
@@ -211,7 +208,10 @@
             this.usingSharedSnaphsotCache = domain != null
                     && objectStore.getDataRowCache() == domain.getSharedSnapshotCache();
         }
-
+	
+	// use a setter to properly initialize EntityResolver
+        setChannel(channel);
+	
         this.graphAction = new DataContextGraphAction(this);
     }
 


> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Andrus Adamchik commented on CAY-1583:
--------------------------------------

DataMergeHandler seems to be your own application class? Doesn't look like a Cayenne class. The problem does look like deserialization issue. Could you give some more details on how it happens and what type of application this is (webapp, etc)

Also is it possible to submit the patch as an output of "svn diff" to provide us some context?



> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (CAY-1583) context.getObjectStore() returning null causing NullpointerException in DataMergeHandler

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

Amaury SECHET edited comment on CAY-1583 at 7/8/11 9:17 PM:
------------------------------------------------------------

Yes you are right, I made a mistake and meant DataContextMergeHandler. Anyway, no, the application doesn't use serialization. This is a quite simple application that process a huge amount of data to put it in a database. The only thing is that tha amount of data is huge and everything is multithreaded, causing this race condition.

Here is the svn diff :

Index: branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
===================================================================
--- branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(révision 1144473)
+++ branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(copie de travail)
@@ -199,9 +199,6 @@
      * @since 1.2
      */
     public DataContext(DataChannel channel, ObjectStore objectStore) {
-        // use a setter to properly initialize EntityResolver
-        setChannel(channel);
-
         // inject self as parent context
         if (objectStore != null) {
             this.objectStore = objectStore;
@@ -211,7 +208,10 @@
             this.usingSharedSnaphsotCache = domain != null
                     && objectStore.getDataRowCache() == domain.getSharedSnapshotCache();
         }
-
+	
+	// use a setter to properly initialize EntityResolver
+        setChannel(channel);
+	
         this.graphAction = new DataContextGraphAction(this);
     }
 


      was (Author: deadalnix):
    Yes you are right, I made a mistake and meant DataContextMergeHandler. Anyway, no, the application doesn't use serialization. This is a quite simple application that process a huge amount of data to put it in a database. The only thing is that tha amount of data is huge and everything is multithreaded, causing this race condition.

Index: branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
===================================================================
--- branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(révision 1144473)
+++ branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java	(copie de travail)
@@ -199,9 +199,6 @@
      * @since 1.2
      */
     public DataContext(DataChannel channel, ObjectStore objectStore) {
-        // use a setter to properly initialize EntityResolver
-        setChannel(channel);
-
         // inject self as parent context
         if (objectStore != null) {
             this.objectStore = objectStore;
@@ -211,7 +208,10 @@
             this.usingSharedSnaphsotCache = domain != null
                     && objectStore.getDataRowCache() == domain.getSharedSnapshotCache();
         }
-
+	
+	// use a setter to properly initialize EntityResolver
+        setChannel(channel);
+	
         this.graphAction = new DataContextGraphAction(this);
     }
 

  
> context.getObjectStore() returning null causing NullpointerException in DataMergeHandler
> ----------------------------------------------------------------------------------------
>
>                 Key: CAY-1583
>                 URL: https://issues.apache.org/jira/browse/CAY-1583
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: sun Java 6 jre under both debian (squeeze) and ubuntu (maverik) linux with MySQL 5.1 using InnoDB.
>            Reporter: Amaury SECHET
>
> context.getObjectStore() return null, but nowhere in the code the constructor is called with null as objectStore
> This looks like a multithreading problem (object accessed before full initialization) or deserialization issue.
> However, I have a patch that's either, solve the issue, or at least make it almost impossible to trigger. Simply switch position of
> 		// use a setter to properly initialize EntityResolver
> 		setChannel(channel);
> 		
> form before the objectContext to after.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira