allthingssecurity commented on code in PR #27693:
URL: https://github.com/apache/camel/pull/27693#discussion_r4249690829
##########
components/camel-pgevent/src/main/java/org/apache/camel/component/pgevent/PgEventConsumer.java:
##########
@@ -102,15 +114,24 @@ public class PgEventListener implements
PGNotificationListener {
public void reconnect() {
Review Comment:
Applied in 57c2101c5564: `reconnect()` returns at once when `isRunAllowed()`
is false, as suggested. I took the guard
and not the alternative (cancel the task after the pool is shut down): the
reconnect pool uses Camel's default
`CallerRuns` rejection policy, and the JDK `CallerRunsPolicy` drops a task
without an exception when the executor is
shut down, so a task created after the shutdown would not fail to schedule,
it would wait forever as well.
One addition: `reconnect()` checks `isRunAllowed()` a second time after it
has set `reconnectTask`, for a stop that
begins between the first check and that write. The status and
`reconnectTask` are both volatile, so either `doStop`
sees the new task and cancels it, or `reconnect()` sees the stop and returns.
Test: `connectionLostWhileStoppingDoesNotStartAReconnect`. The mocked
`UNLISTEN` of the stop starts a thread that
calls `closed()`, waits (Awaitility, 20 s at most) until that thread has
returned or waits, and then fails as on a
lost connection; after the stop the thread must have ended (`join(20 s)` and
`isAlive`), no second connection was
opened and the connection was closed. Without the guard it fails with "the
thread that reported the lost connection
still waits". camel-pgevent: 5 unit tests, 0 failures (the two integration
tests need Docker and were not run). The PR
description is updated.
_Claude Code on behalf of allthingssecurity_
--
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]