debezium/dbz

MongoDbAuthProvider and MongoDbClientFactory lack close() lifecycle for resource cleanup

Open

#1,736 创建于 2026年3月23日

在 GitHub 查看
 (4 评论) (0 反应) (1 负责人)HTML (6 fork)auto 404
component/mongodb-connectorgood first issuetype/task

仓库指标

Star
 (3 star)
PR 合并指标
 (PR 指标待抓取)

描述

Feature request

Description

The MongoDbAuthProvider and MongoDbClientFactory interfaces have no close() method, so implementations that hold closeable resources (e.g. AWS STS clients, HTTP connection pools) have no way to release them when the connector task stops.

Currently, MongoDbConnectorTask.doStop() closes the schema but does not close the MongoDbConnectionContext, which holds the MongoDbClientFactory, which in turn holds the MongoDbAuthProvider. Any resources acquired during init() are never explicitly released.

For the default DefaultMongoDbAuthProvider this is harmless (it holds no closeable resources). However, custom MongoDbAuthProvider implementations — such as those using AWS IAM authentication with STS clients — would benefit from a proper cleanup path.

Proposed change

  1. Add default void close() {} to MongoDbAuthProvider interface
  2. Add default void close() {} to MongoDbClientFactory interface
  3. Override close() in DefaultMongoDbClientFactory to delegate to authProvider.close()
  4. Add close() to MongoDbConnectionContext to delegate to clientFactory.close()
  5. Call connectionContext.close() in MongoDbConnectorTask.doStop()

All default implementations are no-op, so this is fully backward compatible. Custom auth providers can override close() to release their resources.

Affected files

  • MongoDbAuthProvider.java
  • MongoDbClientFactory.java
  • DefaultMongoDbClientFactory.java
  • MongoDbConnectionContext.java
  • MongoDbConnectorTask.java

贡献者指南