[jboss-jira] [JBoss JIRA] (JBSER-120) Can't add field to class as the Java Serialization says is compatible
Jon Onstott (JIRA)
issues at jboss.org
Mon Jul 28 12:25:31 EDT 2014
[ https://issues.jboss.org/browse/JBSER-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12988393#comment-12988393 ]
Jon Onstott commented on JBSER-120:
-----------------------------------
Related stack overflow question: http://stackoverflow.com/questions/17099593/is-there-a-way-to-avoid-jboss-serialization-in-jboss5
> Can't add field to class as the Java Serialization says is compatible
> ---------------------------------------------------------------------
>
> Key: JBSER-120
> URL: https://issues.jboss.org/browse/JBSER-120
> Project: JBoss Serialization
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 1.0.3 GA
> Environment: WIndows 2003 server 64-bit
> Reporter: Tom Saulpaugh
> Assignee: Clebert Suconic
> Fix For: 1.1.0 Beta
>
>
> I traced through this in jboss-serialization and it appears to be a basic coding bug. Look at this code in StreamingClass.readStream(), which includes the exception being thrown:
> short numberofFields=inp.readShort();
> keyfields[slotIndex] = new short[numberofFields];
>
> ClassMetadataField fields[] = slots[slotIndex].getFields();
> if (numberofFields>fields.length)
> {
> throw new IOException("Current classpath has lesser fields on " + className + " than its original version");
> }
> for (short fieldIndex=0;fieldIndex<fields.length;fieldIndex++)
> {
> long hashfield = inp.readLong();
> ClassMetadataField fieldOnHash = slots[slotIndex].getField(hashfield);
> if (fieldOnHash==null)
> {
> throw new IOException ("Field hash " + fieldOnHash + " is not available on current classPath for class " + className);
> }
> keyfields[slotIndex][fieldIndex] = fieldOnHash.getOrder();
> }
> Note that there are numberOfFields fields on the serialized prior version of the object, while there are fields.length fields in the new version of the class being deserialized to. The code reads the serialized fields and looks up the correspondent fields on the new class by hash.
> However, note that it reads fields.length fields from the file instead of numberofFields fields!!!
> That is the problem. It reads a long from the file that is not even a hash code of a field and so can't find it in the hash array, whence the null.
> This really does mean that the latest version of JBoss serialization has a bug that causes it to fail to handle field additions on new versions of classes.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list