DBZ-7935 OlrNetworkClient does not disconnect when error occurs

OlrNetworkClient should disconnect if an unexpected error occurs while reading events from OpenLogReplicator.
This commit is contained in:
jchipmunk 2024-06-09 21:42:45 +03:00 committed by Jiri Pechanec
parent 8662f7ddd8
commit 673ed67a6f

View File

@ -114,6 +114,7 @@ public void execute(ChangeEventSourceContext context, OraclePartition partition,
this.client = new OlrNetworkClient(connectorConfig);
if (client.connect(startScn, startScnIndex)) {
try {
// Start read loop
while (client.isConnected() && context.isRunning()) {
final StreamingEvent event = client.readEvent();
@ -128,10 +129,17 @@ public void execute(ChangeEventSourceContext context, OraclePartition partition,
LOGGER.info("Streaming resumed");
}
}
}
finally {
try {
client.disconnect();
LOGGER.info("Client disconnected.");
}
catch (Exception e) {
LOGGER.error("Exception while disconnecting OpenLogReplicator client", e);
}
}
}
else {
LOGGER.warn("Failed to connect to OpenLogReplicator server.");
}