8000 Fix type comparison in `NumericRange.writeToValueAtRange` by kevinherron · Pull Request #1477 · eclipse-milo/milo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix type comparison in NumericRange.writeToValueAtRange #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged

Conversation

kevinherron
Copy link
Contributor
@kevinherron kevinherron commented May 23, 2025

Allow boxed update values to be written into primitive current values and primitive update values to be written into boxed current values.

fixes #1476

Allow boxed update values to be written into primitive current value and primitive update values to be written into boxed current values.

fixes #1476
@kevinherron kevinherron requested a review from Copilot May 23, 2025 14:02
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that NumericRange.writeToValueAtRange can apply updates between primitive and boxed arrays by comparing boxed base types and instantiating the new array with the correct component type.

  • Added getBoxedType to ArrayUtil (with tests) to normalize primitive vs. wrapper types
  • Updated writeToValueAtRange to use getBoxedType for type checks and to instantiate the result with the original array’s component type
  • Added tests in NumericRangeTest for writing boxed updates into primitive arrays and vice versa

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
stack-core/src/test/java/.../ArrayUtilTest.java New parameterized tests for getBoxedType
stack-core/src/main/java/.../ArrayUtil.java Implemented getBoxedType and updated copyright year
sdk-server/src/test/java/.../NumericRangeTest.java Tests for primitive↔boxed update handling
sdk-core/src/main/java/.../NumericRange.java Use getBoxedType in type comparison and adjust array instantiation and loop
Comments suppressed due to low confidence (1)

opc-ua-sdk/sdk-core/src/main/java/org/eclipse/milo/opcua/sdk/core/NumericRange.java:225

  • The exception message prints the array objects instead of their types. It would be clearer to include the class names, e.g. currentType=%s, updateType=%s, currentType.getName(), updateType.getName()`.
String.format("currentType=%s, updateType=%s", current, update));

@kevinherron kevinherron merged commit 8699d0e into 1.0 May 23, 2025
6 checks passed
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.

Boxed vs primitive comparison in NumericRange
1 participant
0