You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jiri Holy (JIRA)" <ji...@apache.org> on 2014/01/21 01:05:19 UTC

[jira] [Updated] (BEANUTILS-417) java.io.StreamCorruptedException: defaultWriteObject or writeFields not called on the sender's side

     [ https://issues.apache.org/jira/browse/BEANUTILS-417?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jiri Holy updated BEANUTILS-417:
--------------------------------

    Attachment: BEANUTILS-417.patch

Changes order of fields during (de)serialization to comply with spec, test added. Causes incompatibility with serialized instances using previous versions.

> java.io.StreamCorruptedException: defaultWriteObject or writeFields not called on the sender's side
> ---------------------------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-417
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-417
>             Project: Commons BeanUtils
>          Issue Type: Bug
>         Environment: WebSphere Platform 7.0.0.23 [ND 7.0.0.23 cf231218.02] 
> Host Operating System is Linux, version 2.6.32.59-0.7-default
> Java version = JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr10fp1-20120202_101568 (JIT enabled, AOT enabled)
> J9VM - 20120202_101568
> JIT  - r9_20111107_21307ifx1
> GC   - 20120202_AA_CMPRSS, Java Compiler = j9jit24, Java VM name = IBM J9 VM
>            Reporter: krisha
>            Priority: Blocker
>             Fix For: 2.0
>
>         Attachments: BEANUTILS-417.patch
>
>
> The exception is an expected behavior as the implementation of the    
> DynaProperty.readObject and DynaProperty.writeObject do not adhere to 
> the serialization specifications.                                     
> When I looked at the implementation of the write/readObject in           
> org.apache.commons.beanutils.DynaProperty at the link -                  
> (                                                                        
> http://javasourcecode.org/html/open-source/commons-beanutils/commons-bea 
> nutils-1.8.1/org/apache/commons/beanutils/DynaProperty.java.html)        
> I see that they do not adhere to the serialization specification         
> (                                                                        
> http://docs.oracle.com/javase/7/docs/platform/serialization/spec/output. 
> html#861)                                                                
> which states the following -                                             
> Either ObjectOutputStream's defaultWriteObject or writeFields method     
> must be called once (and only once) before writing any optional data     
> that will be needed by the corresponding readObject method to restore    
> the state of the object; even if no optional data is written,            
> defaultWriteObject or writeFields must still be invoked once. If         
> defaultWriteObject or writeFields is not invoked once prior to the       
> writing of optional data (if any), then the behavior of instance         
> deserialization is undefined in cases where the ObjectInputStream cannot 
> resolve the class which defined the writeObject method in question.      
> ------------------------------------------------------------------------ 
> The defaultWriteObject or writeFields have to be invoked prior to        
> writing any data.                                                        
>                                                                          
> A fix was added to the Java 6 SR10 onwards (IX90079), to catch incorrect 
> implementations of the read/writeObjects. Hence, the exception is seen   
> with WAS 7.                                                              
> 3182 [8/24/12 12:13:45:967 EDT] 00000034 ORBRas        3 com.ibm.rmi.io.IIOPInputStream invokeObjectReader:1812 ORB.thread.pool : 0 The following exception was logged
> 3183                                  java.lang.reflect.InvocationTargetException
> 3184 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 3185 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
> 3186 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 3187 	at java.lang.reflect.Method.invoke(Method.java:600)
> 3188 	at com.ibm.rmi.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1809)
> 3189 	at com.ibm.rmi.io.IIOPInputStream.inputObjectUsingClassDesc(IIOPInputStream.java:1529)
> 3190 	at com.ibm.rmi.io.IIOPInputStream.inputObjectClassDesc(IIOPInputStream.java:1504)
> 3191 	at com.ibm.rmi.io.IIOPInputStream.readSerializable(IIOPInputStream.java:1178)
> 3192 	at com.ibm.rmi.io.IIOPInputStream.simpleReadObjectInternal(IIOPInputStream.java:460)
> 3193 	at com.ibm.rmi.io.IIOPInputStream.simpleReadObjectLoop(IIOPInputStream.java:545)
> 3194 	at com.ibm.rmi.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:497)
> 3195 	at com.ibm.rmi.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:210)
> 3196 	at com.ibm.rmi.iiop.CDRReader.read_value(CDRReader.java:1578)
> 3197 	at com.ibm.rmi.iiop.ObjectCopierFactory$AbstractArrayCopier.doWork(ObjectCopierFactory.java:424)
> 3198 	at com.ibm.rmi.iiop.ObjectCopierFactory$AbstractCopier.invoke(ObjectCopierFactory.java:229)
> 3199 	at $Proxy24.doWork(Unknown Source)
> 3200 	at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:118)
> 3201 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1613)
> 3202 Caused by: java.io.StreamCorruptedException: defaultWriteObject or writeFields not called on the sender's side
> 3203 	at com.ibm.rmi.io.IIOPInputStream.defaultReadObject(IIOPInputStream.java:681)
> 3204 	at org.apache.commons.beanutils.DynaProperty.readObject(DynaProperty.java:281)
> 3205 	... 18 more



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)