Skip to content

Use pattern variables in the client SDK - #2130

Open
alxkm wants to merge 1 commit into
eclipse-milo:mainfrom
alxkm:improve/sdk-client-pattern-variables
Open

alxkm wants to merge 1 commit into
eclipse-milo:mainfrom
alxkm:improve/sdk-client-pattern-variables

Conversation

@alxkm

@alxkm alxkm commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Same change as #2092, #2102, #2110 and #2128, for the client SDK. AddressSpace, OpcUaClient, PublishingManager and SessionFsmFactory check a type with instanceof and then cast the same value again in nine places, the form the #1440 inspection skipped. Each now binds a pattern variable. 4 files, 18 lines. These are the last such sites in sdk-client.

No behaviour change. I compared the bytecode of every method in the four classes and their inner classes: the changed methods differ only by the store and load of the new locals. With that undone they match, and every other method is byte for byte identical. One thing worth naming: in OpcUaClient.notifyFaultListeners the pattern variable keeps the result of ex.getCause(), so it is called once instead of twice. mvn verify passes for sdk-client and the integration tests.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Replaces nine instanceof checks followed by casts with pattern variables across four client SDK files.

  • Client type checks now reuse the value they matched.

Reviews (1) · Last reviewed commit: "Use pattern variables in the client SDK" · Reviewed by Greptile

AddressSpace, OpcUaClient, PublishingManager and SessionFsmFactory
check a type with instanceof and then cast the same value again in
nine places, the form the "pattern variable can be used" cleanup in
eclipse-milo#1440 did not pick up. Bind a pattern variable in the instanceof
instead. These are the last such sites in sdk-client.

No behaviour change. I compared the bytecode of every method in the
four classes and their inner classes. The changed methods differ only
by the store and load of the new locals; with that undone they are the
same, and all other methods are byte for byte identical. The one
exception is notifyFaultListeners, where ex.getCause() is now called
once instead of twice, since the pattern variable keeps the result.

Signed-off-by: alxkm <alexanderklmn@gmail.com>
@alxkm
alxkm force-pushed the improve/sdk-client-pattern-variables branch from fa0358b to 151d7a3 Compare October 22, 2026 09:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant