allthingssecurity opened a new pull request, #27323: URL: https://github.com/apache/camel/pull/27323
# Description [CAMEL-25292](https://issues.apache.org/jira/browse/CAMEL-25292) `Plc4XConsumer` with a `trigger` created and started a `TriggeredScraperImpl` and a `TriggerCollectorImpl` in local variables, and `doStop` never stopped them: after the route was stopped the scraper kept reading the PLC and sending exchanges to the route, and after a restart the old and the new scraper both ran, so every triggered read was routed twice (once more per restart). The consumer also created its own `Executors.newSingleThreadScheduledExecutor()` per instance and never shut it down. The triggered consumer could not even start with camel-plc4x alone: the pom excludes `jackson-databind` from `plc4j-scraper`, which `ScraperConfigurationTriggeredImpl` needs (`NoClassDefFoundError: com/fasterxml/jackson/databind/exc/MismatchedInputException` in `doStart`). The existing `Plc4XConsumerTest.shouldStartTriggeredScraperWhenTriggerPresent` stubs `getTrigger()` after creating the consumer, so it runs the untriggered path and did not notice. This change keeps the scraper and the collector and stops them in `doStop`, creates the executor of the one-time read from the `ExecutorServiceManager` and shuts it down in `doStop`, and removes the `jackson-databind` exclusion (a compile dependency of `plc4j-scraper`; the exclusion came with the import of the component in 2022 without a comment; the version comes from Camel's Jackson BOM, 2.22.3 like jackson-core). Note: `TriggeredScraperImpl.stop()` cancels its tasks but does not shut down its own thread pools (PLC4X library). Tests: - `Plc4XConsumerStopTest` (new, scraper and collector replaced with Mockito `mockConstruction`): start and stop a triggered consumer; the scraper and the collector must be stopped. - On main it fails at start with the `NoClassDefFoundError`; with only the pom change it fails with `Wanted but not invoked: triggeredScraperImpl.stop()`. - With the change the module suite passes (18 tests). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built and tested the affected module, including the formatter and import-sort plugins. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
