apache / plc4x

PLC4X The Industrial IoT adapter

Home Page:https://plc4x.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: plc4j-driver-opcua - ArrayStoreException when accessing node by GUID

takraj opened this issue · comments

What happened?

If I attempt to access an OPC-UA node by GUID, I'm getting the following exception:

Exception in thread "main" java.lang.ArrayStoreException: arraycopy: source type java.lang.Long is not an array
	at java.base/java.lang.System.arraycopy(Native Method)
	at org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic.generateNodeId(OpcuaProtocolLogic.java:234)
	at org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic.read(OpcuaProtocolLogic.java:146)
	at org.apache.plc4x.java.spi.optimizer.BaseOptimizer.lambda$optimizedRead$0(BaseOptimizer.java:107)
	at org.apache.plc4x.java.spi.optimizer.BaseOptimizer.send(BaseOptimizer.java:150)
	at org.apache.plc4x.java.spi.optimizer.BaseOptimizer.optimizedRead(BaseOptimizer.java:107)
	at org.apache.plc4x.java.spi.connection.AbstractPlcConnection.read(AbstractPlcConnection.java:167)
	at org.apache.plc4x.java.spi.messages.DefaultPlcReadRequest.execute(DefaultPlcReadRequest.java:60)
	at org.example.ManualOpcuaGuidTag.main(ManualOpcuaGuidTag.java:20)

Example code to reproduce the issue:

PlcDriverManager driverManager = new PlcDriverManager();
try (PlcConnection opcuaConnection = driverManager.getConnection("opcua:tcp://opcuaserver.com:48010")) {
    PlcReadRequest request = opcuaConnection.readRequestBuilder()
            .addItem(
                    "VariableWithGuidNodeId",
                    "ns=2;g=5CE9DBCE-5D79-434C-9AC3-1CFBA9A6E92C"
            )
            .build();

    PlcReadResponse response = request.execute().get();
    System.out.println(response.getObject("VariableWithGuidNodeId"));
}

It applies to the latest revision of develop branch too.
I have already posted a PR to fix it: #1099

Logs

Version

v0.10.0

Programming Languages

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7

fixed with #1099