[jboss-jira] [JBoss JIRA] (JBRULES-3257) MarshallerWriteContext.objectMarshallingStrategyStore contains an unpredictable list of ObjectMarshallingStrategy objects which can break WorkItemInfo unmarshalling (wrt backwards compatibility)

Marco Rietveld (Commented) (JIRA) jira-events at lists.jboss.org
Thu Oct 20 11:42:45 EDT 2011


    [ https://issues.jboss.org/browse/JBRULES-3257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636159#comment-12636159 ] 

Marco Rietveld commented on JBRULES-3257:
-----------------------------------------

So, modifying this code _*breaks*_ backwards compatibility -- but backwards compatibiliy is _already partially_ broken because unmarshalling a FactHandle or WorkItem is dependent on the set of ObjectMarshallingStratagies available. 
                
> MarshallerWriteContext.objectMarshallingStrategyStore contains an unpredictable list of ObjectMarshallingStrategy objects which can break WorkItemInfo unmarshalling (wrt backwards compatibility)   
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-3257
>                 URL: https://issues.jboss.org/browse/JBRULES-3257
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 5.2.0.Final, 5.3.0.Beta1, 5.4.0.Beta1
>            Reporter: Marco Rietveld
>            Assignee: Marco Rietveld
>            Priority: Minor
>             Fix For: 5.4.0.Beta1
>
>
> The reason that this is a minor bug is that the user can always fix this by putting the proper ObjectMarshallingStrategy instance into the environment passed to the object doing the unmarshaller. 
> The following code is where the bug is (see second comment): 
> {code}
> public static void writeWorkItem(MarshallerWriteContext context,
>                                  WorkItem workItem) throws IOException {
>     // ... other code
>     for ( String key : parameters.keySet() ) {
>         Object object = parameters.get( key );
>         if ( object != null ) {
>             stream.writeUTF( key );
>             // Next 2 lines: we store the _index_ of the ObjectMarshallingStrategy object in the stream
>             int index = context.objectMarshallingStrategyStore.getStrategy( object );*
>             stream.writeInt( index );*
>             ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategy( index );
>             if ( strategy.accept( object ) ) {
>                 strategy.write( stream,
>                                 object );
>             }
>         }
>     }
> }         
> {code}
> The logic used above is also used when serializing the FactHandle (see here: [OutputMarshaller (most recent commit)|https://github.com/droolsjbpm/drools/blob/0dc2ef742078138e8747b17093d6ae7163ce0e4a/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java#L396])
> When the marshalled (WorkItem) data is unmarshalled, the {{context.objectMarshallingStrategyStore}} must contain at least the same set of ObjectMarshallingStrategy objects that were used when the WorkItem object was marshalled. 
> ----
> Instead of using the _index_ of the class, my proposed solution is to use the class name, and throw a descriptive exception when the ObjectMarshallingStrategy object sought, can not be found. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list