Sean-Walker0 opened a new pull request, #7640:
URL: https://github.com/apache/shenyu/pull/7640

   Fixes #7635
   
   ## Modifications
   
   `DataChangedEventDispatcher#onApplicationEvent` registered the `afterCommit` 
delivery **only when cluster mode was enabled**. In standalone mode it 
dispatched `DataChangedEvent` synchronously inside the still-open publishing 
transaction — so a rollback left gateways serving a configuration change that 
never reached the database, and listeners could observe uncommitted rows 
mid-transaction.
   
   Delivery is now deferred to `afterCommit` whenever an actual transaction is 
active, regardless of the deployment mode:
   
   ```java
   // dispatch must never overtake the publishing transaction, so an active
   // transaction defers delivery to afterCommit in every deployment mode
   if (TransactionSynchronizationManager.isActualTransactionActive()
           && TransactionSynchronizationManager.isSynchronizationActive()) { 
... registerSynchronization(afterCommit -> dispatch(event)); return; }
   dispatch(event);
   ```
   
   Events published outside a transaction (e.g. full refresh flows) keep 
dispatching immediately — unchanged.
   
   ## Verifying this change
   
   - [x] New 
`DataChangedEventDispatcherTest#onApplicationEventStandaloneWaitsForCommit` — 
cluster disabled, an active transaction synchronization context is opened 
manually, the event is published, and nothing may reach the websocket listener 
until `afterCommit` runs. Red on the pre-fix code (the listener was invoked 
inside the transaction), green after.
   - [x] `./mvnw -pl shenyu-admin -am test -B 
-Dtest=DataChangedEventDispatcherTest` — 19/19 green (18 pre-existing cases, 
including the cluster-mode commit/rollback ones, unchanged), module checkstyle 
clean.
   
   ## Notes
   
   - Behavior change: standalone dispatch inside transactions now happens after 
commit instead of immediately — this is the same guarantee cluster mode already 
provides; the previously uncovered standalone case was reported in #7635.
   - The same test pattern (manual `TransactionSynchronizationManager` context) 
already exists in `DiscoveryServiceImplTest` for the discovery activation 
commit gate.
   - Orthogonality: no open PR modifies `DataChangedEventDispatcher` (verified 
against the file lists of all 70 open PRs).
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true` (module-scoped: `shenyu-admin` targeted test class + 
checkstyle green; full-module suite left to CI as with the other admin PRs).


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

Reply via email to