You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ay...@apache.org on 2007/05/22 12:09:14 UTC
svn commit: r540515 - in /harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/io/ObjectInputStream.java
test/java/tests/api/java/io/ObjectInputStreamTest.java
Author: ayza
Date: Tue May 22 03:09:11 2007
New Revision: 540515
URL: http://svn.apache.org/viewvc?view=rev&rev=540515
Log:
Applying patch from HARMONY-3916 ([classlib][io] Harmony throws unexpected NotActiveException when there's a ObjectInputValidation registered)
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java?view=diff&rev=540515&r1=540514&r2=540515
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectInputStream.java Tue May 22 03:09:11 2007
@@ -2322,7 +2322,7 @@
Object instanceBeingRead = this.currentObject;
// We can't be called from just anywhere. There are rules.
- if (instanceBeingRead == null) {
+ if (instanceBeingRead == null && nestedLevels == 0) {
throw new NotActiveException();
}
if (object == null) {
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java?view=diff&rev=540515&r1=540514&r2=540515
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java Tue May 22 03:09:11 2007
@@ -25,8 +25,10 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InvalidObjectException;
import java.io.NotActiveException;
import java.io.ObjectInputStream;
+import java.io.ObjectInputValidation;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamClass;
import java.io.OutputStream;
@@ -919,8 +921,8 @@
}
}
- // Regression Test for Harmony-2402
public void test_registerValidation() throws Exception {
+ // Regression Test for Harmony-2402
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos);
ObjectInputStream ois = new ObjectInputStream(
@@ -931,6 +933,30 @@
fail("NotActiveException should be thrown");
} catch (NotActiveException nae) {
// expected
+ }
+
+ // Regression Test for Harmony-3916
+ baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(new RegisterValidationClass());
+ oos.close();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream fis = new ObjectInputStream(bais);
+ // should not throw NotActiveException
+ fis.readObject();
+ }
+
+ private static class RegisterValidationClass implements Serializable {
+ private A a = new A();
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+ stream.registerValidation(new MockObjectInputValidation(), 0);
+ }
+ }
+
+ private static class MockObjectInputValidation implements ObjectInputValidation {
+ public void validateObject() throws InvalidObjectException {
+
}
}