-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 04/17/2000
If method setAltNameCtx() is invoked with a non-Serializable parameter,
the object is no longer serializable.
For example, it could be invoked with instance of javax.naming.InitialContext.
In this case object's field 'altNameCtx' will be initialized with
non-Serializable class instance of javax.naming.Context. This causes the
problem.
The test example to reproduce the bug:
-------------------------------------------------------------
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
public class test {
public static void main(String[] args) {
try {
javax.naming.CannotProceedException obj =
new javax.naming.CannotProceedException();
obj.setAltNameCtx(new javax.naming.InitialContext());
FileOutputStream ostream = new FileOutputStream("gold.tmp");
ObjectOutputStream objos = new ObjectOutputStream(ostream);
objos.writeObject(obj);
objos.close();
} catch (java.io.IOException e) {
e.printStackTrace();
} catch (javax.naming.NamingException e) {
}
}
}
-------------------------------------------------------------
Test output:
java.io.NotSerializableException: javax.naming.InitialContext
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
at
java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
at test.main(test.java:14)
-------------------------------------------------------------
======================================================================