Thebas opened a new pull request, #7127:
URL: https://github.com/apache/incubator-kie/pull/7127

   A dynamic fact notifies the session from its setters, so that changing it 
re-evaluates the rules matching it without an explicit update. That 
notification is a JavaBeans PropertyChangeListener registration and the 
listener is the entry point itself, which is not serializable: 
PropertyChangeSupport drops it on write, and the unmarshalled fact comes back 
with an empty listener list. The fact still holds the right values, which makes 
the loss easy to miss, but the engine is never told it changed.
   
   Record the dynamic flag per fact handle in the blob and re-register the 
entry point as the listener on read, for both ways a fact becomes dynamic: an 
insert with the dynamic flag, and a type declared @propertyChangeSupport. The 
second is derivable from the knowledge base and so is also restored for blobs 
written before this change.
   
   ProtobufMessages.java is regenerated from droolsmessages.proto with protoc 
22.5, which reproduces the checked-in file byte for byte, so the diff is 
confined to FactHandle.
   
   Records the dynamic flag per fact handle in the marshalled blob
   (`FactHandle.is_dynamic`, new optional field 13 — 12 is taken by 
`otn_count`) and
   re-registers the entry point as the fact's `PropertyChangeListener` on read.
   
   `ProtobufInputMarshaller.reattachPropertyChangeListener` mirrors what
   `NamedEntryPoint.insert` does on a live insertion: it re-registers when the 
handle
   carries the persisted dynamic flag, or when the fact's type is declared
   `@propertyChangeSupport`, and passes the flag through so `dynamicFacts` is 
rebuilt
   and `removePropertyChangeListener` on delete still works. It deliberately 
does not
   re-attach every fact that happens to expose `addPropertyChangeListener` — 
that would
   give notification to facts inserted without the flag, which
   `plainlyInsertedFact_afterRoundTrip_staysNonDynamic` pins.
   
   `NamedEntryPoint.addPropertyChangeListener` is widened from `protected` to 
`public`
   and `isDynamicFact(handle)` is added, so the marshaller can ask and act. No 
subclass
   overrides either method.
   
   `ProtobufMessages.java` is regenerated from the `.proto` with **protoc 
22.5**, which
   reproduces the checked-in file byte for byte, so the diff is confined to 
`FactHandle`.
   Note for anyone regenerating: the `-Dproto` profile runs whatever `protoc` 
is on
   `PATH`, and a different major version rewrites several thousand unrelated 
lines.
   
   `DynamicFactMarshallingTest` covers a live session (control), a round trip 
after
   `insert(fact, true)`, a round trip with a type declared 
`@propertyChangeSupport`, and
   a round trip after a plain insert (control). The two round-trip dynamic 
cases fail on
   `main`; the two controls pass either way.
   
   Blobs written before this change carry no `is_dynamic` field, so it reads as 
false.
   The `@propertyChangeSupport` half is derivable from the knowledge base and 
therefore
   also restores older blobs; the `insert(fact, true)` half only applies to 
blobs written
   after this change.
   
   Fixes https://github.com/apache/incubator-kie-issues/issues/2407


-- 
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