Skip to content

ticket-777: Fix the bug when IMDS fails during auth token refresh whi… - #780

Open
k2chogori wants to merge 1 commit into
oracle:legacy/v2/masterfrom
k2chogori:github-777
Open

ticket-777: Fix the bug when IMDS fails during auth token refresh whi…#780
k2chogori wants to merge 1 commit into
oracle:legacy/v2/masterfrom
k2chogori:github-777

Conversation

@k2chogori

Copy link
Copy Markdown

Summary

Fixes #777.

When a token refresh fails before the federation request is made, concurrent callers can remain blocked waiting for the shared in-flight refresh result until the timeout expires.

This change ensures that every leader-side refresh failure:

  • completes the shared refresh future exceptionally, releasing current waiting callers immediately;
  • clears the in-flight state so a subsequent caller can begin a new refresh.

The refresh logic is extracted into a focused helper while preserving the existing public API and error behavior.

Testing

  • Added a regression test that simulates a failed refresh of the client certificate before the token request.

  • Verified that a concurrent caller receives the leader’s failure promptly rather than waiting for the single-flight timeout.

  • Ran:

    mvn -pl bmc-common -Dtest=X509FederationClientTest test
    

    Result: 7 tests passed.

[2026/07/29 14:47:02] vianovak ~/workspace/oci-java-sdk [github-777] $ export JAVA_HOME=/Users/vianovak/Library/Java/JavaVirtualMachines/corretto-1.8.0_422/Contents/Home                             
export PATH="$JAVA_HOME/bin:$PATH"
mvn -pl bmc-common -Dtest=X509FederationClientTest test
...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.oracle.bmc.auth.internal.X509FederationClientTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.894 s -- in com.oracle.bmc.auth.internal.X509FederationClientTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- animal-sniffer:1.16:check (animal-sniffer-check) @ oci-java-sdk-common ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java18:1.0
[INFO] /Users/vianovak/workspace/oci-java-sdk/bmc-common/src/main/java/com/oracle/bmc/http/signing/pki/Eraser.java:23: Covariant return type change detected: java.nio.Buffer java.nio.ByteBuffer.clear() has been changed to java.nio.ByteBuffer java.nio.ByteBuffer.clear()
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.576 s
[INFO] Finished at: 2026-07-29T14:49:19Z
[INFO] ------------------------------------------------------------------------

@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

  • PR author: k2chogori

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant