Skip to content

Conversation

@marregui
Copy link
Contributor

@marregui marregui self-assigned this Oct 20, 2025
@cla-bot cla-bot bot added the cla-signed label Oct 20, 2025
Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I hold a few concerns.

}
return errorResponse(new AdapterFailedSchemaValidationError(errorMessages.toErrorList()));
}
}).orElseGet(adapterNotFoundError(adapterId));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adapterNotFoundError(adapterId) to be in a function.

log.error("Failed to restart adapter '{}'.", adapterId, throwable);
} else {
log.trace("Adapter '{}' was restarted successfully.", adapterId);
log.info("Adapter '{}' was restarted successfully.", adapterId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be trace?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That actually has an information character.
I would suggest keeping it at info.
These operations are very low frequence.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I asked this question is the other similar logging statements are all trace ones, but this one is info.

try {
subscription.delete();
} catch (final Exception e) {
log.warn("Failed to delete subscription {}: {}", subscription, e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better log the error stack.

try {
client.removeSubscription(subscription);
} catch (final Exception e) {
log.warn("Failed to remove subscription {}: {}", subscription, e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better log the error stack.

try {
client.removeFaultListener(faultListener);
} catch (final Throwable e) {
log.error("Failed to remove fault listener {}: {}", faultListener, e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better log the error stack.

try {
client.removeSessionActivityListener(activityListener);
} catch (final Throwable e) {
log.error("Failed to remove session activity listener {}: {}", activityListener, e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better log the error stack.

client.disconnect();
log.info("Successfully disconnected OPC UA client");
} catch (final UaException e) {
log.error("Failed to disconnect: {}", e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better log the error stack.

Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion.

} catch (final Exception e) {
log.error("Error closing HikariCP datasource", e);
} finally {
ds = null; // Clear reference to allow GC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion. ds = null; should be executed among all branches.

Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion.

Copy link
Member

@caoccao caoccao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hold some concerns.

StateEnum.ERROR_CLOSING, Set.of(StateEnum.ERROR),
StateEnum.ERROR, Set.of(StateEnum.CONNECTING, StateEnum.DISCONNECTED), // can recover from error
StateEnum.CLOSED, Set.of(StateEnum.DISCONNECTED, StateEnum.CLOSING) // can restart from closed or go to closing
public static final @NotNull Map<StateEnum, Set<StateEnum>> possibleTransitions = Map.of(StateEnum.DISCONNECTED,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose java.util.function.Function<StateEnum, StateEnum> with switch-case inside can outperform this Map.

* @param tags the new tags
*/
public void setTags(final @NotNull List<? extends Tag> tags) {
this.tags = tags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there locking mechanism for protecting these lists? Is it possible the multiple adapters are accessing these lists in parallel?

.whenComplete((result, throwable) -> {
if (throwable != null) {
log.error("Error starting adapter", throwable);
stopProtocolAdapterOnFailedStart();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During this call stopProtocolAdapterOnFailedStart(), currentStartFuture is not null. Is that the expected behavior?

Also if the exception is from the previous throw new RuntimeException("Failed to start consumers", startException);, stopProtocolAdapterOnFailedStart() will be called twice. Is that the expected behavior?

// Transition southbound state to indicate shutdown in progress
final StateEnum currentSouthboundState = currentState().southbound();
if (currentSouthboundState == StateEnum.CONNECTED) {
transitionSouthboundState(StateEnum.DISCONNECTING);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these transitions atomic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants