-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.2beta4
-
sparc
-
solaris_2.5
-
Verified
Name: avC70361 Date: 02/11/98
The java.text.MessageFormat serialization/deserialization process is
incorrectly perfomed. Instances before and after serialization are not equal.
Here is the test demonstrating the bug
-------------MessageFormatTest1.java--------------
import java.text.MessageFormat;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class MessageFormatTest1 {
public static void main(String args[]) {
MessageFormat format1 = null;
MessageFormat format2 = null;
ObjectOutputStream ostream = null;
ByteArrayOutputStream baos = null;
ObjectInputStream istream = null;
try {
ostream = new ObjectOutputStream(
baos = new ByteArrayOutputStream()
);
} catch(IOException e) {
System.out.println("Unexpected exception : " + e);
System.exit(1);
}
try {
format1 = new MessageFormat("pattern{0}");
ostream.writeObject(format1);
ostream.flush();
byte bytes[] = baos.toByteArray();
istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
format2 = (MessageFormat)istream.readObject();
} catch(Exception e) {
System.out.println("Unexpected exception : " + e);
}
if (!format1.equals(format2)) {
System.out.println("MessageFormats before and after serialization are not equal\nformat1 = " + format1 + "(" + format1.toPattern() + ")\nformat2 = " + format2 + "(" + format2.toPattern() + ")");
} else {
System.out.println("OK");
}
}
}
------The test output--------
> java MessageFormatTest1
MessageFormats before and after serialization are not equal
format1 = java.text.MessageFormat@d0d8eb90(pattern{0})
format2 = java.text.MessageFormat@d0d8eb90(pattern{0})
======================================================================