You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/09/15 14:15:09 UTC
svn commit: r575910 - in /cayenne/main/branches/STABLE-1.2/cayenne:
cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/
cayenne-java/src/tests/java/org/objectstyle/cayenne/access/
cayenne-java/src/tests/resources/dml/ cayenne-other/release-no...
Author: aadamchik
Date: Sat Sep 15 05:15:09 2007
New Revision: 575910
URL: http://svn.apache.org/viewvc?rev=575910&view=rev
Log:
Deserialization of DataContext fails when useSharedCache is false - CAY-796
Added:
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.DataContextSerializationTst.xml
Modified:
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowStore.java
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextSerializationTst.java
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt
Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java?rev=575910&r1=575909&r2=575910&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java Sat Sep 15 05:15:09 2007
@@ -453,6 +453,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/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowStore.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowStore.java?rev=575910&r1=575909&r2=575910&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowStore.java (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowStore.java Sat Sep 15 05:15:09 2007
@@ -729,7 +729,10 @@
}
void stopListeners() {
- eventManager.removeListener(this);
+ if (eventManager != null) {
+ eventManager.removeListener(this);
+ }
+
if (remoteNotificationsHandler != null) {
try {
remoteNotificationsHandler.shutdown();
@@ -742,29 +745,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/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextSerializationTst.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextSerializationTst.java?rev=575910&r1=575909&r2=575910&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextSerializationTst.java (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/DataContextSerializationTst.java Sat Sep 15 05:15:09 2007
@@ -60,6 +60,7 @@
import org.apache.log4j.Logger;
import org.objectstyle.art.Artist;
+import org.objectstyle.cayenne.DataObjectUtils;
import org.objectstyle.cayenne.PersistenceState;
import org.objectstyle.cayenne.conf.Configuration;
import org.objectstyle.cayenne.unit.CayenneTestCase;
@@ -74,6 +75,7 @@
protected void setUp() throws Exception {
fixSharedConfiguration();
+ deleteTestData();
}
protected void fixSharedConfiguration() {
@@ -111,6 +113,8 @@
}
public void testSerializeWithSharedCache() throws Exception {
+
+ createTestData("prepare");
DataContext context = createDataContextWithSharedCache();
@@ -130,9 +134,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 = createDataContextWithLocalCache();
@@ -154,6 +165,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/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.DataContextSerializationTst.xml
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.DataContextSerializationTst.xml?rev=575910&view=auto
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.DataContextSerializationTst.xml (added)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/tests/resources/dml/access.DataContextSerializationTst.xml Sat Sep 15 05:15:09 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans default-lazy-init="true">
+
+ <bean id="INSERT" class="org.objectstyle.cayenne.unit.util.UpdatingSQLTemplate">
+ <constructor-arg type="java.lang.Class"><value>org.objectstyle.art.Artist</value></constructor-arg>
+ <constructor-arg><value>
+ insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (33001, 'aaa')
+ </value></constructor-arg>
+ </bean>
+
+
+ <!-- ======================================= -->
+ <!-- Data Sets -->
+ <!-- ======================================= -->
+
+ <bean id="prepare" class="java.util.ArrayList">
+ <constructor-arg>
+ <list>
+ <ref bean="INSERT"/>
+ </list>
+ </constructor-arg>
+ </bean>
+</beans>
Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt?rev=575910&r1=575909&r2=575910&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.4.txt Sat Sep 15 05:15:09 2007
@@ -10,5 +10,6 @@
Bug Fixes:
+CAY-796 Deserialization of DataContext fails when useSharedCache is false
CAY-818 Frontbase NUMBERIC type mapping typo
CAY-832 enum-mapped columns improperly handled in in expressions