Skip to content

feat: make Hive2Namespace and Hive3Namespace Closeable#137

Merged
jackye1995 merged 1 commit into
lance-format:mainfrom
puchengy:hive-namespace-closeable
Jun 25, 2026
Merged

feat: make Hive2Namespace and Hive3Namespace Closeable#137
jackye1995 merged 1 commit into
lance-format:mainfrom
puchengy:hive-namespace-closeable

Conversation

@puchengy

@puchengy puchengy commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What

Make Hive2Namespace and Hive3Namespace implement java.io.Closeable and add a close() that closes the underlying Hive*ClientPool.

Why

Both Hive namespaces own a Hive*ClientPool — which implements Closeable and holds a pool of live Hive Metastore client connections — but neither exposed any way to release it. So a consumer holding a Hive*Namespace cannot release its metastore connections and leaks them when the instance is discarded.

Every other client-backed implementation in this repo already handles this:

Impl implements Closeable? closes its client in close()?
IcebergNamespace ✅ (restClient)
GlueNamespace ✅ (glueClient)
UnityNamespace ✅ (restClient)
PolarisNamespace ✅ (restClient)
Hive2Namespace ❌ → ✅ — → ✅ (clientPool)
Hive3Namespace ❌ → ✅ — → ✅ (clientPool)

The two Hive namespaces were the only exceptions; this brings them in line with the rest.

Changes

  • Hive2Namespace / Hive3Namespace: implements LanceNamespace, Closeable; add close() that closes clientPool.
  • close() is null-safe (no-op if initialize() was never called) and idempotent (ClientPoolImpl.close() already guards with a closed flag).
  • Add unit tests for both behaviors in TestHive2Namespace and TestHive3Namespace: testCloseReleasesClientPool (initialize → use → close twice) and testCloseBeforeInitializeIsSafe.

Testing

  • ./mvnw spotless:check -pl lance-namespace-hive2 and -pl lance-namespace-hive3 — pass.
  • ./mvnw test -pl lance-namespace-hive2 -Dtest='!*Integration' — 17 tests, 0 failures (incl. the 2 new tests).
  • ./mvnw test -pl lance-namespace-hive3 -Dtest='!*Integration' — 25 tests, 0 failures (incl. the 2 new tests).

@github-actions github-actions Bot added enhancement New feature or request java labels Jun 25, 2026
@puchengy puchengy force-pushed the hive-namespace-closeable branch from f1e968d to 61a8bd9 Compare June 25, 2026 19:51
Both Hive2Namespace and Hive3Namespace own a Hive*ClientPool, which
implements Closeable and holds a pool of live Hive Metastore client
connections. Neither namespace exposed any way to release that pool.

Every other client-backed implementation in this repo already implements
Closeable and closes its underlying client/pool in close() (Iceberg, Glue,
Unity, Polaris); the two Hive namespaces were the only exceptions, so a
caller holding a Hive*Namespace has no way to release its metastore
connections and leaks them when the instance is discarded.

Implement Closeable on both classes with a close() that closes the client
pool. close() is null-safe (a no-op when initialize() was never called) and
idempotent (ClientPoolImpl.close() already guards with a closed flag). Add
unit tests for both behaviors in TestHive2Namespace and TestHive3Namespace.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@puchengy puchengy force-pushed the hive-namespace-closeable branch from 61a8bd9 to 9a2d75e Compare June 25, 2026 19:54

@jackye1995 jackye1995 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for the fix!

@jackye1995 jackye1995 merged commit d1bd474 into lance-format:main Jun 25, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants