mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
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:
@@ -210,13 +210,12 @@ public class CanalRabbitMQProducer extends AbstractMQProducer implements CanalMQ
|
|||||||
try {
|
try {
|
||||||
this.channel.close();
|
this.channel.close();
|
||||||
this.connect.close();
|
this.connect.close();
|
||||||
super.stop();
|
|
||||||
} catch (AlreadyClosedException ex) {
|
} catch (AlreadyClosedException ex) {
|
||||||
logger.error("Connection is already closed", ex);
|
logger.error("Connection is already closed", ex);
|
||||||
} catch (IOException | TimeoutException ex) {
|
} catch (IOException | TimeoutException ex) {
|
||||||
throw new CanalException("Stop RabbitMQ producer error", ex);
|
throw new CanalException("Stop RabbitMQ producer error", ex);
|
||||||
|
} finally {
|
||||||
|
super.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user