Fix type comparison in NumericRange.writeToValueAtRange#1477
Merged
kevinherron merged 2 commits into1.0from May 23, 2025
Merged
Fix type comparison in NumericRange.writeToValueAtRange#1477kevinherron merged 2 commits into1.0from
NumericRange.writeToValueAtRange#1477kevinherron merged 2 commits into1.0from
Conversation
Allow boxed update values to be written into primitive current value and primitive update values to be written into boxed current values. fixes #1476
Contributor
There was a problem hiding this comment.
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
getBoxedTypetoArrayUtil(with tests) to normalize primitive vs. wrapper types - Updated
writeToValueAtRangeto usegetBoxedTypefor type checks and to instantiate the result with the original array’s component type - Added tests in
NumericRangeTestfor 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));
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow boxed update values to be written into primitive current values and primitive update values to be written into boxed current values.
fixes #1476