Skip to content

[#14148] fix(core): Clear GravitinoEnv components on shutdown - #14149

Draft
nevzheng wants to merge 1 commit into
apache:mainfrom
nevzheng:claude/14148-gravitinoenv-shutdown-reset
Draft

nevzheng wants to merge 1 commit into
apache:mainfrom
nevzheng:claude/14148-gravitinoenv-shutdown-reset

Conversation

@nevzheng

@nevzheng nevzheng commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Nevin

What changes were proposed in this pull request?

  • Fix: shutdown() now ends with clearComponents(), which sets every component field back to
    its initial value after closing them.
  • Tests: new TestGravitinoEnvShutdown checks that an injected authorizer, internal access
    control dispatcher and metrics system are gone after shutdown(). The KMS and secret registry
    tests now expect their getters to throw after shutdown instead of returning the closed instance.

Why are the changes needed?

A closed component left in the singleton leaks into whatever runs next in the JVM. The test-side
fixes in #14099, #14100 and #14102 work around three symptoms; this removes the cause.

Fix: #14148

Does this PR introduce any user-facing change?

No. After shutdown(), getters return null or throw instead of returning closed components.
GravitinoServer.stop() calls shutdown() after the HTTP server stops, so no request sees the
cleared state.

How was this patch tested?

./gradlew :core:spotlessCheck :core:test --tests 'org.apache.gravitino.TestGravitinoEnv*' -PskipITs passes: 10 tests in TestGravitinoEnvShutdown, TestGravitinoEnvKmsClientRegistry, TestGravitinoEnvSecretProviderRegistry and TestGravitinoEnvMetadataComponents, no failures.

@nevzheng nevzheng self-assigned this Oct 22, 2026
@nevzheng nevzheng mentioned this pull request Oct 22, 2026
10 tasks
GravitinoEnv is a JVM-wide singleton, and shutdown() closed its components
but kept the references. A later initialization or test in the same JVM then
saw closed components (MetricsSystem) or doubles an earlier test injected
(authorizer, internal access control dispatcher), which caused the
order-dependent failures fixed test-side in apache#14099, apache#14100 and apache#14102.
@nevzheng
nevzheng force-pushed the claude/14148-gravitinoenv-shutdown-reset branch from 38e155e to 9be3e1f Compare October 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug report] GravitinoEnv.shutdown() keeps references to closed components

1 participant