Robin Mattes created CAMEL-23819:
------------------------------------
Summary: camel-milo (browse): NullPointerException in Camel Milo
Browse with Siemens S7
Key: CAMEL-23819
URL: https://issues.apache.org/jira/browse/CAMEL-23819
Project: Camel
Issue Type: Bug
Components: camel-milo
Affects Versions: 4.20.0
Reporter: Robin Mattes
Component: camel-milo (OPC UA Browse Producer)
*Problem:*
When browsing the OPC UA node tree of a Siemens S7 PLC, a NullPointerException
occurred in MiloBrowseProducer. The S7's OPC UA server returns null for
BrowseResult.getReferences() on certain nodes (e.g., leaf nodes or nodes
without child references), rather than returning an empty array. The stream
pipeline in the browse result processing did not account for this, causing a
NPE when Stream::of was called on a null reference array.
*Root Cause:*
The code at MiloBrowseProducer.java:114 assumed that
BrowseResult.getReferences() always returns a non-null array. The Siemens S7
OPC UA server implementation violates this assumption by returning null
references for nodes that have no children or for which browsing is not
applicable.
*Solution:*
A .filter(Objects::nonNull) step was added to the stream pipeline between
.map(BrowseResult::getReferences) and .flatMap(Stream::of). This filters out
any null reference arrays before they are passed to Stream::of, gracefully
skipping nodes without references instead of crashing.
_Claude Code on behalf of Robin Mattes_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)