fix: ensure super.stop() is called exactly once in CanalRabbitMQProducer (#5578)

Previously super.stop() was called both inside the try block and after
the catch blocks. On success it was invoked twice; on IOException it was
never reached. Move super.stop() to a finally block so it executes
exactly once regardless of whether close() succeeds or fails.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guimu
2026-04-23 14:09:05 +08:00
committed by GitHub
parent 5110cfd49d
commit 8a5dc38a58

View File

@@ -210,13 +210,12 @@ public class CanalRabbitMQProducer extends AbstractMQProducer implements CanalMQ
try {
this.channel.close();
this.connect.close();
super.stop();
} catch (AlreadyClosedException ex) {
logger.error("Connection is already closed", ex);
} catch (IOException | TimeoutException ex) {
throw new CanalException("Stop RabbitMQ producer error", ex);
} finally {
super.stop();
}
super.stop();
}
}