Skip to content

UaNode.getProperty() fails to decode ExtensionObject values #1662

@kevinherron

Description

@kevinherron

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 ExtensionObject value
  • Array: ExtensionObject[] array
  • Matrix: Matrix containing ExtensionObject[] elements

Expected Behavior

When getProperty() is called with a QualifiedProperty<T>, it should:

  1. Retrieve the raw property value
  2. Detect if the value is an ExtensionObject (or array/matrix thereof)
  3. Automatically decode the ExtensionObject using the server's encoding context
  4. 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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions