Skip to content

CAMEL-25280: camel-snmp - concurrent exchanges on one endpoint must not share the request PDU - #27309

Merged
davsclaus merged 1 commit into
apache:mainfrom
allthingssecurity:camel-snmp-producer-concurrent-requests
Oct 3, 2026
Merged

davsclaus merged 1 commit into
apache:mainfrom
allthingssecurity:camel-snmp-producer-concurrent-requests

Conversation

@allthingssecurity

Copy link
Copy Markdown
Contributor

Description

CAMEL-25280

Follow-up of #27242 (CAMEL-25245), as suggested in its review.

SnmpProducer kept one request PDU in a field, created in doStart. The producer of an endpoint is shared by all its concurrent exchanges, and the GET_NEXT walk changes that PDU for every request (clear(), then the next OID). SNMP4J also encodes the same PDU object again when it retries after a timeout. So walks running at the same time on one endpoint changed each other's requests: a walk whose request was retried while another walk ran got the answer for the other walk's last OID, ended its subtree early and returned an incomplete list, without an error.

This change creates the request PDU for each exchange (the code that built it in doStart moves to a method that process calls).

Tests:

  • ConcurrentWalkTest (new): an SNMP4J test agent with two subtrees that does not answer the very first request. A first walk starts; once its first request was dropped, a second walk runs on the same endpoint while the first waits for its retry.
  • Without the change the first walk returns [b1, b2] instead of [a1, a2, b1, b2].
  • With the change all camel-snmp tests pass: 16 tests, 0 failures.

Conflicts with #27242: both change the lines of the walk loop. The same change applied on top of #27242 passes there too (22 tests); whichever is merged second needs a small rebase (the walk uses the local pdu instead of this.pdu).

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • 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

  • 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

…ot share the request PDU

SnmpProducer is shared by all the exchanges of an endpoint, and kept one request PDU in a field. The GET_NEXT walk
changes that PDU for every request (clear, then the next OID), and SNMP4J sends the same PDU object again when it
retries after a timeout. So walks running at the same time on one endpoint changed each other's requests: a walk
whose request was retried while another walk ran got the answer for the other walk's last OID, ended its subtree
early and returned a silently incomplete result.

The producer now creates the request PDU for each exchange.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The request PDU is now built per exchange, so concurrent walks and SNMP4J retries no longer share and mutate one PDU. The latch-based ConcurrentWalkTest is a nice reproduction.

Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-snmp

🔬 Scalpel shadow comparison — Scalpel: 9 of 698 tested, 27 compile-only — current: 9 all tested

Maveniverse Scalpel detected 9 affected modules (current approach: 9).

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-route-parser ← downstream of org.apache.camel:camel-route-parser
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-yaml-dsl-validator
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
  • camel-snmp ← components/camel-snmp/src/main/java/org/apache/camel/component/snmp/SnmpProducer.java, components/camel-snmp/src/test/java/org/apache/camel/component/snmp/ConcurrentWalkTest.java
  • camel-yaml-dsl-validator ← downstream of org.apache.camel:camel-catalog
  • camel-yaml-dsl-validator-maven-plugin ← downstream of org.apache.camel:camel-yaml-dsl-validator
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (36 modules, 5m 43s total)

Total reactor time: 5m 43s

Module Duration Status
Camel :: Launcher 47.8s SUCCESS
Camel :: JBang :: Plugin :: TUI 42.9s SUCCESS
Camel :: JBang :: MCP 37.6s SUCCESS
Camel :: Catalog :: Camel Catalog 24.2s SUCCESS
Camel :: YAML DSL :: Validator 19.8s SUCCESS
Camel :: YAML DSL 19.4s SUCCESS
Camel :: Component DSL 19.3s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 17.9s SUCCESS
Camel :: Docs 15.8s SUCCESS
Camel :: SNMP 12.7s SUCCESS
Camel :: Kamelet Main 12.0s SUCCESS
Camel :: YAML DSL :: Deserializers 8.9s SUCCESS
Camel :: JBang :: Plugin :: Testing 8.7s SUCCESS
Camel :: Catalog :: Camel Route Parser 8.3s SUCCESS
Camel :: YAML DSL :: Validator Maven Plugin 7.8s SUCCESS
Camel :: Catalog :: Camel Report Maven Plugin 7.3s SUCCESS
Camel :: All Components Sync point 5.8s SUCCESS
Camel :: JBang :: Plugin :: Validate 5.4s SUCCESS
Camel :: YAML DSL :: Maven Plugins 3.8s SUCCESS
Camel :: Catalog :: Maven 3.1s SUCCESS
Camel :: Catalog :: Suggest (deprecated) 2.5s SUCCESS
Camel :: Assembly 1.5s SUCCESS
Camel :: Coverage 1.4s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.4s SUCCESS
Camel :: Catalog :: Console 1.2s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.2s SUCCESS
Camel :: Catalog :: Dummy Component 1.2s SUCCESS
Camel :: Endpoint DSL :: Support 0.8s SUCCESS
Camel :: JBang :: Main 0.8s SUCCESS
Camel :: JBang :: Integration tests 0.7s SUCCESS
Camel :: Launcher :: Container 0.7s SUCCESS
Camel :: JBang :: Plugin :: MCP 0.6s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 0.6s SUCCESS
Camel :: Endpoint DSL n/a
Camel :: Integration Tests n/a
Camel :: JBang :: Core n/a

Top 20 slowest modules:

  • Camel :: Launcher (47.8s)
  • Camel :: JBang :: Plugin :: TUI (42.9s)
  • Camel :: JBang :: MCP (37.6s)
  • Camel :: Catalog :: Camel Catalog (24.2s)
  • Camel :: YAML DSL :: Validator (19.8s)
  • Camel :: YAML DSL (19.4s)
  • Camel :: Component DSL (19.3s)
  • Camel :: JBang :: Plugin :: Kubernetes (17.9s)
  • Camel :: Docs (15.8s)
  • Camel :: SNMP (12.7s)
  • Camel :: Kamelet Main (12.0s)
  • Camel :: YAML DSL :: Deserializers (8.9s)
  • Camel :: JBang :: Plugin :: Testing (8.7s)
  • Camel :: Catalog :: Camel Route Parser (8.3s)
  • Camel :: YAML DSL :: Validator Maven Plugin (7.8s)
  • Camel :: Catalog :: Camel Report Maven Plugin (7.3s)
  • Camel :: All Components Sync point (5.8s)
  • Camel :: JBang :: Plugin :: Validate (5.4s)
  • Camel :: YAML DSL :: Maven Plugins (3.8s)
  • Camel :: Catalog :: Maven (3.1s)

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.23.0 milestone Oct 3, 2026
@davsclaus davsclaus added the bug Something isn't working label Oct 3, 2026
@davsclaus
davsclaus merged commit 6e56206 into apache:main Oct 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants