[jboss-jira] [JBoss JIRA] (JBSER-128) Unable to deserialize Vector when using JDK 7

Clebert Suconic (JIRA) jira-events at lists.jboss.org
Wed May 1 23:13:53 EDT 2013


     [ https://issues.jboss.org/browse/JBSER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Clebert Suconic updated JBSER-128:
----------------------------------

    Assignee: Brad Maxwell  (was: Clebert Suconic)

    
> Unable to deserialize Vector when using JDK 7
> ---------------------------------------------
>
>                 Key: JBSER-128
>                 URL: https://issues.jboss.org/browse/JBSER-128
>             Project: JBoss Serialization
>          Issue Type: Bug
>    Affects Versions: 1.0.5.FINAL
>         Environment: JBoss EAP 5.2 on JDK 7
>            Reporter: Brad Maxwell
>            Assignee: Brad Maxwell
>
> JDK 7 changed the writeObject of Vector, 
> ObjectOutputStreamProxy.writeFields is being called, which write the fields out not as a FinalContainer , writeMyself checks the type and for non FinalContainer it just writes the object in metho FieldsContainer.writeField as:
>             out.writeByte(DataContainerConstants.OBJECTREF);
>             out.writeObject(value);
> When reading, RegularObjectPersister is expecting all FinalContainer.
> So it looks like either FinalContainer.writeField may need to wrap the objects in a FinalContainer or on the reading side it needs to read the non wrapped fields before reading the wrapped fields.
> public void writeFields() throws IOException {
>         if (currentContainer!=null)
>         {
>             currentContainer.writeMyself(this);
>             currentContainer=null;
>         }
> JDK 6
> --------------------------------------------------------------------------
> public class Vector<E>
>     extends AbstractList<E>
>     private synchronized void writeObject(java.io.ObjectOutputStream s)
>         throws java.io.IOException
>     {
>   s.defaultWriteObject();
>     }
> JDK 7
> --------------------------------------------------------------------------
>     private void writeObject(java.io.ObjectOutputStream s)
>             throws java.io.IOException {
>         final java.io.ObjectOutputStream.PutField fields = s.putFields();
>         final Object[] data;
>         synchronized (this) {
>             fields.put("capacityIncrement", capacityIncrement);
>             fields.put("elementCount", elementCount);
>             data = elementData.clone();
>         }
>         fields.put("elementData", data);
>         s.writeFields();
>     }
> org.jboss.serial.exception.SerializationException: Excepted to be int
>         at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readInt(DataContainer.java:1050)
>         at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:333)
>         at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:290)
>         at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:258)
>         at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
>         at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
>         at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:847)
>         at test.Serial.main(Serial.java:28)
> Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to org.jboss.serial.finalcontainers.IntegerContainer
>         at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readInt(DataContainer.java:1046)
>         ... 7 more
> java.io.EOFException
>         at java.io.DataInputStream.readFully(DataInputStream.java:197)
>         at org.jboss.serial.util.StringUtil.pullDataToBuffer(StringUtil.java:191)
>         at org.jboss.serial.util.StringUtil.readString(StringUtil.java:238)
>         at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectInput.readUTF(DataContainer.java:757)
>         at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:322)
>         at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:290)
>         at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:258)
>         at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
>         at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
>         at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectInput.readObject(DataContainer.java:643)
>         at org.jboss.serial.io.JBossObjectInputStream.readObjectOverride(JBossObjectInputStream.java:163)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:363)
>         at test.Serial.main(Serial.java:48)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list