Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3257

MarshallerWriteContext.objectMarshallingStrategyStore contains an unpredictable list of ObjectMarshallingStrategy objects which can break WorkItemInfo unmarshalling (wrt backwards compatibility)

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 5.4.0.Beta1
    • 5.2.0.Final, 5.3.0.Beta1, 5.4.0.Beta1
    • drools-core
    • 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

          Activity

            People

              marco.rietveld Marco Rietveld (Inactive)
              marco.rietveld Marco Rietveld (Inactive)
              Archiver:
              rhn-support-ceverson Clark Everson

              Dates

                Created:
                Updated:
                Resolved:
                Archived:

                PagerDuty