Details
-
Bug
-
Resolution: Done
-
Minor
-
5.2.0.Final, 5.3.0.Beta1, 5.4.0.Beta1
-
None
-
Low
Description
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):
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 ); } } } }
The logic used above is also used when serializing the FactHandle (see here: OutputMarshaller (most recent commit))
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.
Attachments
Issue Links
- relates to
-
JBPM-3414 MarshallerWriteContext.objectMarshallingStrategyStore contains an unpredictable list of ObjectMarshallingStrategy objects which can break Variable unmarshalling (wrt backwards compatibility)
- Resolved