sarutak opened a new pull request, #57677:
URL: https://github.com/apache/spark/pull/57677

   ### What changes were proposed in this pull request?
   This PR adds `AutoCloseable` to the `CredentialProvider` interface so that 
implementations holding long-lived resources (e.g., HTTP connection pools in 
`StsClient`) can be properly cleaned up on shutdown.
   
   - `CredentialProvider` now extends `AutoCloseable` with a default no-op 
`close()` 
   - `CredentialProviderLoader.closeAll()` closes all initialized providers 
with exception suppression (first exception wins, others attached via 
`addSuppressed`)
   - `UserCredentialManager.stop()` calls `closeAll()` during shutdown
   
   ### Why are the changes needed?
   Unlike `HadoopDelegationTokenProvider` (which is stateless, and receives 
config on each `obtainDelegationTokens()` call), `CredentialProvider` uses an 
`init()` pattern where implementations construct long-lived resources. For 
example, `AwsStsCredentialProvider` (#57655) holds an `StsClient` with HTTP 
connection pools that must be closed. Without a lifecycle hook, these resources 
leak on application shutdown.
   
   Adding `AutoCloseable` (rather than a standalone `close()` method) follows 
the same pattern as `KVStore` and `DataWriter` in Spark . It serves as a 
lifecycle contract marker indicating that implementations may hold resources, 
and the framework is responsible for calling `close()` at shutdown. It is not 
intended for use with try-with-resources.
   
   ### Does this PR introduce _any_ user-facing change?
   No. The default `close()` is a no-op; existing `CredentialProvider` 
implementations are unaffected.
   
   ### How was this patch tested?
   - CredentialProviderLoaderSuite: 3 new tests for closeAll()
   - UserCredentialManagerSuite: 1 new test for stop() closing providers
   - All 47 tests pass
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Kiro CLI / Claude
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to