You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GH-10362: Fix PostgresSubscribableChannel for race condition
Fixes: #10362
Unsubscribing message handlers while processing an in-flight message may lead to a `MessageDeliveryException`.
There is a possibility in the `PostgresSubscribableChannel` to have a polled message dispatched when no subscribers to the channel anymore.
The `doPollAndDispatchMessage()` can enter to the `pollMessage()` when it sees `hasHandlers`.
However, the last subscriber to the channel is unsubscribed in parallel.
* Fix `PostgresSubscribableChannel` using a `ReadWriteLock` to block `unsubscribe()` until currently polled message is processed.
Or opposite: do not let to `doPollAndDispatchMessage()` to enter `pollMessage()` logic until `unsubscribe()` is done.
This way the `hasHandlers` state is guarded by lock synchronization.
Signed-off-by: Norbert Schneider <[email protected]>
**Auto-cherry-pick to `6.4.x`**
# Conflicts:
# spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresSubscribableChannel.java
Copy file name to clipboardExpand all lines: spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/channel/PostgresSubscribableChannel.java
Copy file name to clipboardExpand all lines: spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/postgres/PostgresChannelMessageTableSubscriberTests.java
0 commit comments