Return-Path: Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: (qmail 24466 invoked from network); 15 Sep 2007 12:21:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Sep 2007 12:21:03 -0000 Received: (qmail 72146 invoked by uid 500); 15 Sep 2007 12:20:56 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 72125 invoked by uid 500); 15 Sep 2007 12:20:56 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 72116 invoked by uid 99); 15 Sep 2007 12:20:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Sep 2007 05:20:56 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Sep 2007 12:20:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D1BBD1A9832; Sat, 15 Sep 2007 05:20:34 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575911 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/ framework/cayenne-jdk... Date: Sat, 15 Sep 2007 12:20:34 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070915122034.D1BBD1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aadamchik Date: Sat Sep 15 05:20:33 2007 New Revision: 575911 URL: http://svn.apache.org/viewvc?rev=575911&view=rev Log: CAY-796 Deserialization of DataContext fails when useSharedCache is false Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=575911&r1=575910&r2=575911&view=diff ============================================================================== --- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original) +++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sat Sep 15 05:20:33 2007 @@ -36,6 +36,7 @@ Bug Fixes Since M1: +CAY-796 Deserialization of DataContext fails when useSharedCache is false CAY-797 Lifecycle callbacks *CallbackInterceptor concept introduces problems for testing equality of contexts CAY-832 enum-mapped columns improperly handled in in expressions CAY-835 setting meaningful pk to zero turn on autogenerated keys Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?rev=575911&r1=575910&r2=575911&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java Sat Sep 15 05:20:33 2007 @@ -370,6 +370,14 @@ // guarantee that a new channel uses the same EventManager. EventUtil.listenForChannelEvents(channel, mergeHandler); } + + if (!usingSharedSnaphsotCache && getObjectStore() != null) { + DataRowStore cache = getObjectStore().getDataRowCache(); + + if (cache != null) { + cache.setEventManager(eventManager); + } + } } } } Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java?rev=575911&r1=575910&r2=575911&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataRowStore.java Sat Sep 15 05:20:33 2007 @@ -594,7 +594,10 @@ } void stopListeners() { - eventManager.removeListener(this); + if (eventManager != null) { + eventManager.removeListener(this); + } + if (remoteNotificationsHandler != null) { try { remoteNotificationsHandler.shutdown(); @@ -607,29 +610,36 @@ } void startListeners() { - if (remoteNotificationsHandler != null) { - try { - // listen to EventBridge ... must add itself as non-blocking listener - // otherwise a deadlock can occur as "processRemoteEvent" will attempt to - // obtain a lock on this object when the dispatch queue is locked... And - // another commit thread may have this object locked and attempt to lock - // dispatch queue + if (eventManager != null) { + if (remoteNotificationsHandler != null) { + try { + // listen to EventBridge ... must add itself as non-blocking listener + // otherwise a deadlock can occur as "processRemoteEvent" will attempt + // to + // obtain a lock on this object when the dispatch queue is locked... + // And + // another commit thread may have this object locked and attempt to + // lock + // dispatch queue - eventManager.addNonBlockingListener( - this, - "processRemoteEvent", - SnapshotEvent.class, - getSnapshotEventSubject(), - remoteNotificationsHandler); + eventManager.addNonBlockingListener( + this, + "processRemoteEvent", + SnapshotEvent.class, + getSnapshotEventSubject(), + remoteNotificationsHandler); - // start EventBridge - it will listen to all event sources for this - // subject - remoteNotificationsHandler.startup( - eventManager, - EventBridge.RECEIVE_LOCAL_EXTERNAL); - } - catch (Exception ex) { - throw new CayenneRuntimeException("Error initializing DataRowStore.", ex); + // start EventBridge - it will listen to all event sources for this + // subject + remoteNotificationsHandler.startup( + eventManager, + EventBridge.RECEIVE_LOCAL_EXTERNAL); + } + catch (Exception ex) { + throw new CayenneRuntimeException( + "Error initializing DataRowStore.", + ex); + } } } } Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java?rev=575911&r1=575910&r2=575911&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSerializationTest.java Sat Sep 15 05:20:33 2007 @@ -22,6 +22,7 @@ import java.util.List; import org.apache.art.Artist; +import org.apache.cayenne.DataObjectUtils; import org.apache.cayenne.PersistenceState; import org.apache.cayenne.conf.Configuration; import org.apache.cayenne.unit.CayenneCase; @@ -34,6 +35,7 @@ protected void setUp() throws Exception { fixSharedConfiguration(); + deleteTestData(); } protected void fixSharedConfiguration() { @@ -71,6 +73,8 @@ } public void testSerializeWithSharedCache() throws Exception { + + createTestData("prepare"); DataContext context = createDataContextWithSharedCache(); @@ -90,9 +94,16 @@ assertNotNull(deserializedContext.getEntityResolver()); assertSame(context.getEntityResolver(), deserializedContext.getEntityResolver()); + + Artist a = (Artist) DataObjectUtils.objectForPK(deserializedContext, Artist.class, 33001); + assertNotNull(a); + a.setArtistName(a.getArtistName() + "___"); + deserializedContext.commitChanges(); } public void testSerializeWithLocalCache() throws Exception { + + createTestData("prepare"); DataContext context = createDataContextWithDedicatedCache(); @@ -114,6 +125,13 @@ assertNotSame( deserializedContext.getParentDataDomain().getSharedSnapshotCache(), deserializedContext.getObjectStore().getDataRowCache()); + + Artist a = (Artist) DataObjectUtils.objectForPK(deserializedContext, Artist.class, 33001); + assertNotNull(a); + a.setArtistName(a.getArtistName() + "___"); + + // this blows per CAY-796 + deserializedContext.commitChanges(); } public void testSerializeNew() throws Exception { Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml?rev=575911&view=auto ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml (added) +++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/dml/access.DataContextSerializationTest.xml Sat Sep 15 05:20:33 2007 @@ -0,0 +1,25 @@ + + + + + + + org.apache.art.Artist + + insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33001, 'aaa') + + + + + + + + + + + + + + + + \ No newline at end of file