]
Marco Rietveld updated JBRULES-3257:
------------------------------------
Comment: was deleted
(was: 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/0dc2ef742078138e8747b17...
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: