United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6690068 REG: serialization proccess throws NPE
JDK-6690068 : REG: serialization proccess throws NPE

Details
Type:
Bug
Submit Date:
2008-04-17
Status:
Resolved
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2008-05-07
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10 (b23)

Related Reports
Relates:
Relates:
Relates:

Sub Tasks

Description
Deserialization of any container throws NPE due to a missed initilization inside readObject() method.
 private void readObject(ObjectInputStream s)throws ClassNotFoundException, IOException{
        ObjectInputStream.GetField f = s.readFields();
        Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY);
>>        component.addAll(Arrays.asList(tmpComponent));

This is a regression of CR 6616323.

                                    

Comments
SUGGESTED FIX

Should assign some default value to this field:
 private void readObject(ObjectInputStream s)throws ClassNotFoundException, IOException{
        ObjectInputStream.GetField f = s.readFields();
        Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY);
+       component = new java.util.ArrayList<Component>();
        component.addAll(Arrays.asList(tmpComponent));
                                     
2008-04-17
EVALUATION

Collection isn't initialized while de-serial process runs. Should assign it some empty ArrayList.
                                     
2008-04-18
SUGGESTED FIX

http://sa.sfbay.sun.com/projects/awt_data/6u10/6690068/
                                     
2008-04-18



Hardware and Software, Engineered to Work Together