tkobayas commented on code in PR #7127:
URL: https://github.com/apache/incubator-kie/pull/7127#discussion_r4102167097


##########
drools-serialization-protobuf/src/main/java/org/drools/serialization/protobuf/ProtobufInputMarshaller.java:
##########
@@ -425,12 +425,33 @@ public static void readFactHandles( 
ProtobufMarshallerReaderContext context,
                 assertHandleIntoOTN( context, wm, handle, pctxs );
             }
 
+            reattachPropertyChangeListener( entryPoint, handle );
+
             if (handle.isExpired()) {
                 wm.addPropagation(new 
WorkingMemoryReteExpireAction((DefaultEventHandle) handle));
             }
         }
     }
 
+    /**
+     * Restores the listener for types declared with {@code 
@propertyChangeSupport}.
+     * JavaBeans PropertyChangeSupport drops the non-serializable entry point 
listener
+     * during marshalling, so it must be registered again on read.
+     */
+    private static void reattachPropertyChangeListener( EntryPoint entryPoint,
+                                                        InternalFactHandle 
handle ) {
+        Object object = handle.getObject();
+        if ( object == null || !(entryPoint instanceof NamedEntryPoint) ) {
+            return;
+        }
+        NamedEntryPoint namedEntryPoint = (NamedEntryPoint) entryPoint;
+        ObjectTypeConf typeConf = 
namedEntryPoint.getObjectTypeConfigurationRegistry()
+                .getOrCreateObjectTypeConf( namedEntryPoint.getEntryPoint(), 
object );
+        if ( typeConf.isDynamic() ) {
+            namedEntryPoint.addPropertyChangeListener( handle, false );

Review Comment:
   This is intentional. We limit the scope of the fix to @propertyChangeSupport 
only.
   `insert(fact, true)` is deprecated. -> 
https://github.com/apache/incubator-kie/issues/7132



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to