From fa5084c495c97c1eaa101e944e54c04e2ef4f82e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:45:30 +0000 Subject: [PATCH 1/3] Initial plan From 9fbce29ee555f65bd98355c2f1129355354bf5eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:00:28 +0000 Subject: [PATCH 2/3] Add public reset methods for lazy OpcUaClient fields Co-authored-by: kevinherron <340273+kevinherron@users.noreply.github.com> --- .../milo/opcua/sdk/client/OpcUaClient.java | 44 ++++++++++++++++--- .../client/OpcUaClientResetMethodsTest.java | 32 ++++++++++++++ 2 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java diff --git a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java index e61b20ee9..5bee3a46b 100644 --- a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java +++ b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/OpcUaClient.java @@ -659,6 +659,11 @@ public DataTypeManager getDynamicDataTypeManager() throws UaException { () -> dynamicDataTypeManagerFactory.create(this, getNamespaceTable(), getDataTypeTree())); } + /** Reset the cached dynamic {@link DataTypeManager}. */ + public void resetDynamicDataTypeManager() { + dynamicDataTypeManager.reset(); + } + /** * Get a "static" {@link EncodingContext} instance. * @@ -713,6 +718,11 @@ public ServerTable getServerTable() { }); } + /** Reset the cached dynamic {@link EncodingContext}. */ + public void resetDynamicEncodingContext() { + dynamicEncodingContext.reset(); + } + /** * Get the local copy of the server's NamespaceTable (NamespaceArray). * @@ -892,6 +902,11 @@ public DataTypeTree getDataTypeTree() throws UaException { } } + /** Reset the cached {@link DataTypeTree}. */ + public void resetDataTypeTree() { + dataTypeTree.reset(); + } + /** * Read the {@link DataTypeTree} from the server and update the local copy. * @@ -899,7 +914,7 @@ public DataTypeTree getDataTypeTree() throws UaException { * @throws UaException if an error occurs while reading the DataTypes. */ public DataTypeTree readDataTypeTree() throws UaException { - dataTypeTree.reset(); + resetDataTypeTree(); return getDataTypeTree(); } @@ -936,6 +951,11 @@ public ObjectTypeTree getObjectTypeTree() throws UaException { } } + /** Reset the cached {@link ObjectTypeTree}. */ + public void resetObjectTypeTree() { + objectTypeTree.reset(); + } + /** * Read the {@link ObjectTypeTree} from the server and update the local copy. * @@ -943,7 +963,7 @@ public ObjectTypeTree getObjectTypeTree() throws UaException { * @throws UaException if an error occurs while reading the ObjectTypes. */ public ObjectTypeTree readObjectTypeTree() throws UaException { - objectTypeTree.reset(); + resetObjectTypeTree(); return getObjectTypeTree(); } @@ -981,6 +1001,11 @@ public VariableTypeTree getVariableTypeTree() throws UaException { } } + /** Reset the cached {@link VariableTypeTree}. */ + public void resetVariableTypeTree() { + variableTypeTree.reset(); + } + /** * Read the {@link VariableTypeTree} from the server and update the local copy. * @@ -988,7 +1013,7 @@ public VariableTypeTree getVariableTypeTree() throws UaException { * @throws UaException if an error occurs while reading the VariableTypes. */ public VariableTypeTree readVariableTypeTree() throws UaException { - variableTypeTree.reset(); + resetVariableTypeTree(); return getVariableTypeTree(); } @@ -1023,6 +1048,11 @@ public OperationLimits getOperationLimits() throws UaException { return operationLimits.getOrThrow(() -> OperationLimits.read(this)); } + /** Reset the cached {@link OperationLimits}. */ + public void resetOperationLimits() { + operationLimits.reset(); + } + /** * Read the server's OperationLimits and update the local copy. * @@ -1030,7 +1060,7 @@ public OperationLimits getOperationLimits() throws UaException { * @throws UaException if an error occurs reading the operation limits. */ public OperationLimits readOperationLimits() throws UaException { - operationLimits.reset(); + resetOperationLimits(); return getOperationLimits(); } @@ -1099,7 +1129,7 @@ public RequestHeader newRequestHeader(NodeId authToken, UInteger requestTimeout) public void setDataTypeTreeFactory(DataTypeTreeFactory dataTypeTreeFactory) { this.dataTypeTreeFactory = dataTypeTreeFactory; - dataTypeTree.reset(); + resetDataTypeTree(); } /** @@ -1125,8 +1155,8 @@ public void setDynamicDataTypeManagerFactory( this.dynamicDataTypeManagerFactory = dynamicDataTypeManagerFactory; - dynamicDataTypeManager.reset(); - dynamicEncodingContext.reset(); + resetDynamicDataTypeManager(); + resetDynamicEncodingContext(); } // region Attribute Services diff --git a/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java b/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java new file mode 100644 index 000000000..bb60da6d7 --- /dev/null +++ b/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java @@ -0,0 +1,32 @@ +package org.eclipse.milo.opcua.sdk.client; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.List; +import org.junit.jupiter.api.Test; + +class OpcUaClientResetMethodsTest { + + @Test + void lazyBackedFieldsHavePublicResetMethods() throws Exception { + List resetMethods = + List.of( + "resetOperationLimits", + "resetDynamicDataTypeManager", + "resetDynamicEncodingContext", + "resetDataTypeTree", + "resetObjectTypeTree", + "resetVariableTypeTree"); + + for (String resetMethod : resetMethods) { + Method method = OpcUaClient.class.getMethod(resetMethod); + + assertEquals(void.class, method.getReturnType()); + assertTrue(Modifier.isPublic(method.getModifiers())); + assertEquals(0, method.getParameterCount()); + } + } +} From 88cb7a1494da31e0adf7a9c340e3a57586c8b0cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:16:04 +0000 Subject: [PATCH 3/3] Remove unnecessary OpcUaClientResetMethodsTest Co-authored-by: kevinherron <340273+kevinherron@users.noreply.github.com> --- .../client/OpcUaClientResetMethodsTest.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java diff --git a/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java b/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java deleted file mode 100644 index bb60da6d7..000000000 --- a/opc-ua-sdk/sdk-client/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientResetMethodsTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.eclipse.milo.opcua.sdk.client; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.List; -import org.junit.jupiter.api.Test; - -class OpcUaClientResetMethodsTest { - - @Test - void lazyBackedFieldsHavePublicResetMethods() throws Exception { - List resetMethods = - List.of( - "resetOperationLimits", - "resetDynamicDataTypeManager", - "resetDynamicEncodingContext", - "resetDataTypeTree", - "resetObjectTypeTree", - "resetVariableTypeTree"); - - for (String resetMethod : resetMethods) { - Method method = OpcUaClient.class.getMethod(resetMethod); - - assertEquals(void.class, method.getReturnType()); - assertTrue(Modifier.isPublic(method.getModifiers())); - assertEquals(0, method.getParameterCount()); - } - } -}