[CVS nanning] Fixed a bug where objects could not be created after a snapshot had been read. Was a issue with not reinitializing the nextObjectId.
Lecando Shared <[email protected]> Thu, 27 Nov 2003 09:54:19 -0600
| Newsgroups | gmane.comp.java.nanning.devel |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>nanning/src/frameworks/prevayler/src</tt></b> on <span id="info">MAIN</span></td></tr>
<tr><td><tt>main/org/codehaus/nanning/prevayler/<a href="#file1">BasicIdentifyingSystem.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-11</td><td nowrap="nowrap" align="center">1.7 -> 1.8</td></tr>
<tr class="alt"><td><tt>test/org/codehaus/nanning/prevayler/<a href="#file2">PrevaylerTest.java</a></tt></td><td align="right" id="added">+25</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">1.11 -> 1.12</td></tr>
<tr><td></td><td align="right" id="added">+26</td><td align="right" id="removed">-16</td><td></td></tr>
</table>
<small id="info">2 modified files</small><br />
<pre class="comment">
Fixed a bug where objects could not be created after a snapshot had been read. Was a issue with not reinitializing the nextObjectId.
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/main/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>BasicIdentifyingSystem.java</b></big> <small id="info">1.7 -> 1.8</small></div>
<pre class="diff"><small id="info">diff -u -r1.7 -r1.8
--- BasicIdentifyingSystem.java 30 Sep 2003 12:33:43 -0000 1.7
+++ BasicIdentifyingSystem.java 27 Nov 2003 15:54:18 -0000 1.8
@@ -154,6 +154,7 @@
</small></pre><pre class="diff" id="context"> }
for (Iterator i = readBackValues.iterator(); i.hasNext();) {
Identifiable identifiable = (Identifiable) i.next();
</pre><pre class="diff" id="added">+ nextObjectId = Math.max(identifiable.getObjectID() + 1, nextObjectId);
</pre><pre class="diff" id="context"> register(identifiable);
}
readBackValues = null;
</pre><pre class="diff"><small id="info">@@ -163,15 +164,4 @@
</small></pre><pre class="diff" id="context"> return nextObjectId++;
}
</pre><pre class="diff" id="removed">- public synchronized void clear() {
- for (Iterator i = idToObject.values().iterator(); i.hasNext();) {
- IdentifiableSoftReference reference = (IdentifiableSoftReference) i.next();
- Identifiable identifiable = (Identifiable) reference.get();
- if (identifiable != null) {
- identifiable.clearObjectID();
- }
- i.remove();
- }
- nextObjectId = 0;
- }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">nanning/src/frameworks/prevayler/src/test/org/codehaus/nanning/prevayler<br /></span>
<div class="fileheader"><big><b>PrevaylerTest.java</b></big> <small id="info">1.11 -> 1.12</small></div>
<pre class="diff"><small id="info">diff -u -r1.11 -r1.12
--- PrevaylerTest.java 8 Oct 2003 07:25:40 -0000 1.11
+++ PrevaylerTest.java 27 Nov 2003 15:54:18 -0000 1.12
@@ -2,9 +2,10 @@
</small></pre><pre class="diff" id="context">
import java.io.*;
import java.lang.reflect.Method;
</pre><pre class="diff" id="removed">-import java.util.HashMap;
</pre><pre class="diff" id="context"> import java.util.Date;
</pre><pre class="diff" id="added">+import java.util.HashMap;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+import junit.framework.Assert;
</pre><pre class="diff" id="context"> import org.codehaus.nanning.AspectInstance;
import org.codehaus.nanning.Aspects;
import org.codehaus.nanning.Mixin;
</pre><pre class="diff"><small id="info">@@ -13,7 +14,6 @@
</small></pre><pre class="diff" id="context"> import org.codehaus.nanning.config.AspectSystem;
import org.codehaus.nanning.config.FindTargetMixinAspect;
import org.prevayler.PrevaylerFactory;
</pre><pre class="diff" id="removed">-import junit.framework.Assert;
</pre><pre class="diff" id="context">
public class PrevaylerTest extends AbstractAttributesTest {
</pre><pre class="diff"><small id="info">@@ -25,9 +25,9 @@
</small></pre><pre class="diff" id="context"> super.setUp();
assertTrue("attributes not compiled or not on classpath (add 'target/attributes' to classpath)",
</pre><pre class="diff" id="removed">- <span id="removedchars"> </span>PrevaylerUtils.isTransactional(MySystem.class.getMethod("setMyObject", new Class[]{MyObject.class})));
</pre><pre class="diff" id="added">+ PrevaylerUtils.isTransactional(MySystem.class.getMethod("setMyObject", new Class[]{MyObject.class})));
</pre><pre class="diff" id="context"> assertTrue("attributes not compiled or not on classpath (add 'target/attributes' to classpath)",
</pre><pre class="diff" id="removed">- <span id="removedchars"> </span>PrevaylerUtils.isTransactional(MySystem.class.getMethod("setSimpleString", new Class[]{String.class})));
</pre><pre class="diff" id="added">+ PrevaylerUtils.isTransactional(MySystem.class.getMethod("setSimpleString", new Class[]{String.class})));
</pre><pre class="diff" id="context">
aspectSystem = new AspectSystem();
aspectSystem.addAspect(new FindTargetMixinAspect());
</pre><pre class="diff"><small id="info">@@ -497,6 +497,26 @@
</small></pre><pre class="diff" id="context"> });
}
</pre><pre class="diff" id="added">+ public void testCreatingObjectsAfterSnapshotIsTakenSystemRestarted() throws Exception {
+ newPrevayler();
+ withCurrentPrevayler(new PrevaylerAction() {
+ public Object run() {
+ currentSystem().setMyObject((MyObject) currentSystem().newInstance(MyObject.class));
+ return null;
+ }
+ });
+
+ // restoring
+ currentPrevayler.takeSnapshot();
+ newPrevayler();
+ withCurrentPrevayler(new PrevaylerAction() {
+ public Object run() {
+ currentSystem().getMyObject().setMyObject((MyObject) currentSystem().newInstance(MyObject.class));
+ return null;
+ }
+ });
+ }
+
</pre><pre class="diff" id="context"> public void testSerialization() throws IOException, ClassNotFoundException {
MyObject myObject = (MyObject) aspectSystem.newInstance(MyObject.class);
myObject.setValue("value");
</pre><pre class="diff"><small id="info">@@ -523,7 +543,7 @@
</small></pre><pre class="diff" id="context"> private void newPrevayler() throws IOException, ClassNotFoundException {
currentPrevayler = new CountingPrevayler(
PrevaylerFactory.createPrevayler((Serializable) Aspects.getCurrentAspectFactory().newInstance(MySystem.class),
</pre><pre class="diff" id="removed">- <span id="removedchars"> </span>prevaylerDir.getAbsolutePath()));
</pre><pre class="diff" id="added">+ prevaylerDir.getAbsolutePath()));
</pre><pre class="diff" id="context"> }
public interface TestUnsupportedTransaction {
</pre></div>
</body></html>