Skip to content

Commit 50cb121

Browse files
authored
Fix/shutdown order (#1128)
* Changed order of events during shutdown * Ensure the activity listener can't trigger too early
1 parent 326c3ca commit 50cb121

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/hivemq-edge-module-opcua/src/main/java/com/hivemq/edge/adapters/opcua/OpcUaClientConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class OpcUaClientConnection {
104104
endpointFilter,
105105
ignore -> {},
106106
new OpcUaClientConfigurator(adapterId, parsedConfig));
107-
client.addSessionActivityListener(activityListener);
108107
client.addFaultListener(faultListener);
109108
client.connect();
110109
} catch (final UaException e) {
@@ -122,13 +121,13 @@ class OpcUaClientConnection {
122121

123122
if(subscriptionOptional.isEmpty()) {
124123
log.error("Failed to create or transfer OPC UA subscription. Closing client connection.");
125-
quietlyCloseClient(client, false,null, null);
126124
protocolAdapterState.setConnectionStatus(ProtocolAdapterState.ConnectionStatus.ERROR);
127125
eventService
128126
.createAdapterEvent(adapterId, PROTOCOL_ID_OPCUA)
129127
.withMessage("Failed to create or transfer OPC UA subscription. Closing client connection.")
130128
.withSeverity(Event.SEVERITY.ERROR)
131129
.fire();
130+
quietlyCloseClient(client, false, faultListener, activityListener);
132131
return false;
133132
}
134133

@@ -137,6 +136,7 @@ class OpcUaClientConnection {
137136

138137
context.set(new ConnectionContext(subscription.getClient(), faultListener, activityListener));
139138
protocolAdapterState.setConnectionStatus(ProtocolAdapterState.ConnectionStatus.CONNECTED);
139+
client.addSessionActivityListener(activityListener);
140140
log.info("Client created and connected successfully");
141141
return true;
142142
}

0 commit comments

Comments
 (0)