-
Notifications
You must be signed in to change notification settings - Fork 474
Description
Description
The UaNode.getProperty(QualifiedProperty<T>) method does not properly handle properties whose values are stored as ExtensionObject instances. When retrieving such properties, the method returns the encoded ExtensionObject instead of decoding it to the expected type, causing a ClassCastException when the caller attempts to cast the result.
This affects properties containing structured types stored as ExtensionObject in three forms:
- Scalar: Single
ExtensionObjectvalue - Array:
ExtensionObject[]array - Matrix:
MatrixcontainingExtensionObject[]elements
Expected Behavior
When getProperty() is called with a QualifiedProperty<T>, it should:
- Retrieve the raw property value
- Detect if the value is an
ExtensionObject(or array/matrix thereof) - Automatically decode the
ExtensionObjectusing the server's encoding context - Return the decoded value cast to the expected type
T
Actual Behavior
The method returns the ExtensionObject directly without decoding, causing a ClassCastException when the caller expects the decoded structured type.
Root Cause
The getProperty() method in opc-ua-sdk/sdk-server/src/main/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNode.java simply retrieves the property value and casts it without checking if decoding is needed:
return getProperty(browseName).map(property.getJavaType()::cast);