Skip to content

Handle concurrent monitored item resets - #1815

Merged
kevinherron merged 2 commits into
mainfrom
codex/handle-concurrent-monitored-item-resets
Jul 21, 2026
Merged

Handle concurrent monitored item resets#1815
kevinherron merged 2 commits into
mainfrom
codex/handle-concurrent-monitored-item-resets

Conversation

@kevinherron

Copy link
Copy Markdown
Contributor

Summary

  • return per-item Bad_InvalidState results when monitored item server state disappears during SetMonitoringMode or DeleteMonitoredItems request construction
  • continue processing valid items while preserving caller-order result alignment
  • document the non-throwing behavior for items without server state
  • add deterministic regression coverage for both reset timing windows, never-created items, and the sibling deletion race

Root cause

A monitored item's syncState and serverState are separate volatile fields. Session reactivation or concurrent deletion can clear them between setMonitoringMode() validation and the later monitored-item ID lookup, causing either IllegalArgumentException or NoSuchElementException. The deletion path used the same throwing ID lookup pattern.

Impact

Callers now receive a Bad_InvalidState service result for each affected item instead of a race-dependent exception. Valid items in the same request are still sent to the server and their results remain aligned with the original input list.

Validation

  • mise exec -- mvn -q spotless:apply
  • mise exec -- mvn -q -pl opc-ua-sdk/integration-tests -am test -Dtest=OpcUaMonitoredItemTest -Dsurefire.failIfNoSpecifiedTests=false
  • mise exec -- mvn -q clean compile

Fixes #1814

Report Bad_InvalidState when per-item server state disappears while
building monitoring mode or deletion requests. This avoids leaking
race-dependent exceptions while preserving request and result alignment.

Fixes #1814
@kevinherron
kevinherron marked this pull request as ready for review July 21, 2026 22:34
@kevinherron
kevinherron merged commit eb4ee91 into main Jul 21, 2026
6 checks passed
@kevinherron kevinherron added this to the 1.1.6 milestone Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpcUaSubscription.setMonitoringMode throws NoSuchElementException when a MonitoredItem's server state is cleared concurrently

1 participant