Skip to content

Fix CI failure in TestJettyHttpsClientSpnego.testNegotiateAuthScheme#130

Closed
nishithakbhaskaran wants to merge 1 commit into
prestodb:masterfrom
nishithakbhaskaran:test
Closed

Fix CI failure in TestJettyHttpsClientSpnego.testNegotiateAuthScheme#130
nishithakbhaskaran wants to merge 1 commit into
prestodb:masterfrom
nishithakbhaskaran:test

Conversation

@nishithakbhaskaran

@nishithakbhaskaran nishithakbhaskaran commented Nov 6, 2025

Copy link
Copy Markdown

Fix CI Failure in testNegotiateAuthScheme()

Fixes https://github.com/prestodb/airlift/actions/runs/19124887710/job/54653069038?pr=129

Error:  Tests run: 432, Failures: 1, Errors: 0, Skipped: 9, Time elapsed: 178.516 s <<< FAILURE! - in TestSuite
Error:  testNegotiateAuthScheme(com.facebook.airlift.http.client.jetty.TestJettyHttpsClientSpnego)  Time elapsed: 0.096 s  <<< FAILURE!
java.lang.RuntimeException: Failed to establish LoginContext for request https://localhost:39313/
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.authenticate(SpnegoAuthentication.java:168)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.lambda$apply$0(SpnegoAuthentication.java:133)
	at net.jodah.failsafe.Functions.lambda$supplierOf$12(Functions.java:296)
	at net.jodah.failsafe.Functions.lambda$resultSupplierOf$11(Functions.java:283)
	at net.jodah.failsafe.internal.executor.RetryPolicyExecutor.lambda$supply$0(RetryPolicyExecutor.java:67)
	at net.jodah.failsafe.Execution.executeSync(Execution.java:117)
	at net.jodah.failsafe.FailsafeExecutor.call(FailsafeExecutor.java:319)
	at net.jodah.failsafe.FailsafeExecutor.run(FailsafeExecutor.java:219)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.apply(SpnegoAuthentication.java:133)
	at org.eclipse.jetty.client.AuthenticationProtocolHandler$AuthenticationListener.onComplete(AuthenticationProtocolHandler.java:226)
	at com.facebook.airlift.http.client.spnego.ForwardingResponseListener.onComplete(ForwardingResponseListener.java:68)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthenticationProtocolHandler$1.onComplete(SpnegoAuthenticationProtocolHandler.java:52)
	at org.eclipse.jetty.client.transport.ResponseListeners.notifyComplete(ResponseListeners.java:354)
	at org.eclipse.jetty.client.transport.ResponseListeners.notifyComplete(ResponseListeners.java:346)
	at org.eclipse.jetty.client.transport.HttpReceiver.terminateResponse(HttpReceiver.java:454)
	at org.eclipse.jetty.client.transport.HttpReceiver.terminateResponse(HttpReceiver.java:436)
	at org.eclipse.jetty.client.transport.HttpReceiver.lambda$responseSuccess$4(HttpReceiver.java:394)
	at org.eclipse.jetty.util.thread.SerializedInvoker$Link.run(SerializedInvoker.java:274)
	at org.eclipse.jetty.util.thread.SerializedInvoker.run(SerializedInvoker.java:174)
	at org.eclipse.jetty.client.transport.HttpReceiver.responseHeaders(HttpReceiver.java:247)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:335)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parseAndFill(HttpReceiverOverHTTP.java:252)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:85)
	at org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:97)
	at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:267)
	at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP$FillableCallback.succeeded(HttpConnectionOverHTTP.java:458)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.onFillable(SslConnection.java:614)
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:415)
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:156)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:54)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:521)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.epcRunTask(AdaptiveExecutionStrategy.java:492)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:447)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:297)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:202)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:312)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:1009)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1239)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1194)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: javax.security.auth.login.LoginException: KrbException: Cannot locate default realm
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:633)
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:597)
	at java.base/javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
	at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:679)
	at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:677)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.base/javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:677)
	at java.base/javax.security.auth.login.LoginContext.login(LoginContext.java:587)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication.getSession(SpnegoAuthentication.java:236)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.authenticate(SpnegoAuthentication.java:141)
	... 41 more
Caused by: KrbException: KrbException: Cannot locate default realm
	at java.security.jgss/sun.security.krb5.Realm.getDefault(Realm.java:66)
	at java.security.jgss/sun.security.krb5.PrincipalName.<init>(PrincipalName.java:479)
	at java.security.jgss/sun.security.krb5.PrincipalName.<init>(PrincipalName.java:489)
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:630)
	... 50 more
Caused by: KrbException: Cannot locate default realm
	at java.security.jgss/sun.security.krb5.Config.getDefaultRealm(Config.java:1219)
	at java.security.jgss/sun.security.krb5.Realm.getDefault(Realm.java:62)
	... 53 more

2025-11-06T04:38:52.510Z	INFO	Thread-3834	com.facebook.airlift.bootstrap.LifeCycleManager	Life cycle stopping...
2025-11-06T04:38:52.510Z	INFO	Thread-3756	com.facebook.airlift.bootstrap.LifeCycleManager	Life cycle stopping...
[INFO] 
[INFO] Results:
[INFO] 
Error:  Failures: 
Error:    TestJettyHttpsClientSpnego.testNegotiateAuthScheme » Runtime Failed to establi...

@nishithakbhaskaran nishithakbhaskaran force-pushed the test branch 2 times, most recently from 9eee3c1 to 609aa16 Compare November 6, 2025 07:33
@nishithakbhaskaran nishithakbhaskaran changed the title TEST Fix CI failure in TestJettyHttpsClientSpnego.testNegotiateAuthScheme Nov 6, 2025
@nishithakbhaskaran nishithakbhaskaran marked this pull request as ready for review November 6, 2025 07:51
@nishithakbhaskaran nishithakbhaskaran requested a review from a team as a code owner November 6, 2025 07:51
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR resolves a CI failure by updating the test annotation for testNegotiateAuthScheme so that it expects a RuntimeException with the correct message pattern instead of UncheckedIOException.

File-Level Changes

Change Details Files
Adjust test annotation to match the thrown exception type and message
  • Updated expectedExceptions from UncheckedIOException to RuntimeException
  • Refined expectedExceptionsMessageRegExp to correctly match the error message
http-client/src/test/java/com/facebook/airlift/http/client/jetty/TestJettyHttpsClientSpnego.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Use a more specific exception type for SPNEGO authentication failures rather than the generic RuntimeException to make error handling clearer.
  • Add a brief comment in the test explaining why the expected exception was changed to RuntimeException to document this behavioral change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Use a more specific exception type for SPNEGO authentication failures rather than the generic RuntimeException to make error handling clearer.
- Add a brief comment in the test explaining why the expected exception was changed to RuntimeException to document this behavioral change.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

}

@Test(expectedExceptions = UncheckedIOException.class, expectedExceptionsMessageRegExp = ".* Failed to establish LoginContext for request .*")
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Failed to establish LoginContext for request .*")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new exception is (correctly) a RuntimeException -

java.lang.RuntimeException: Failed to establish LoginContext for request https://localhost:39313/
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.authenticate(SpnegoAuthentication.java:168)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.lambda$apply$0(SpnegoAuthentication.java:133)
	at net.jodah.failsafe.Functions.lambda$supplierOf$12(Functions.java:296)
	at net.jodah.failsafe.Functions.lambda$resultSupplierOf$11(Functions.java:283)
	at net.jodah.failsafe.internal.executor.RetryPolicyExecutor.lambda$supply$0(RetryPolicyExecutor.java:67)
	at net.jodah.failsafe.Execution.executeSync(Execution.java:117)
	at net.jodah.failsafe.FailsafeExecutor.call(FailsafeExecutor.java:319)
	at net.jodah.failsafe.FailsafeExecutor.run(FailsafeExecutor.java:219)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.apply(SpnegoAuthentication.java:133)
	at org.eclipse.jetty.client.AuthenticationProtocolHandler$AuthenticationListener.onComplete(AuthenticationProtocolHandler.java:226)
	at com.facebook.airlift.http.client.spnego.ForwardingResponseListener.onComplete(ForwardingResponseListener.java:68)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthenticationProtocolHandler$1.onComplete(SpnegoAuthenticationProtocolHandler.java:52)
	at org.eclipse.jetty.client.transport.ResponseListeners.notifyComplete(ResponseListeners.java:354)
	at org.eclipse.jetty.client.transport.ResponseListeners.notifyComplete(ResponseListeners.java:346)
	at org.eclipse.jetty.client.transport.HttpReceiver.terminateResponse(HttpReceiver.java:454)
	at org.eclipse.jetty.client.transport.HttpReceiver.terminateResponse(HttpReceiver.java:436)
	at org.eclipse.jetty.client.transport.HttpReceiver.lambda$responseSuccess$4(HttpReceiver.java:394)
	at org.eclipse.jetty.util.thread.SerializedInvoker$Link.run(SerializedInvoker.java:274)
	at org.eclipse.jetty.util.thread.SerializedInvoker.run(SerializedInvoker.java:174)
	at org.eclipse.jetty.client.transport.HttpReceiver.responseHeaders(HttpReceiver.java:247)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:335)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.parseAndFill(HttpReceiverOverHTTP.java:252)
	at org.eclipse.jetty.client.transport.internal.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:85)
	at org.eclipse.jetty.client.transport.internal.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:97)
	at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:267)
	at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP$FillableCallback.succeeded(HttpConnectionOverHTTP.java:458)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.onFillable(SslConnection.java:614)
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:415)
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:156)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:54)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:521)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.epcRunTask(AdaptiveExecutionStrategy.java:492)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:447)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:297)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:202)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:312)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:1009)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1239)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1194)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: javax.security.auth.login.LoginException: KrbException: Cannot locate default realm
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:633)
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:597)
	at java.base/javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
	at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:679)
	at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:677)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.base/javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:677)
	at java.base/javax.security.auth.login.LoginContext.login(LoginContext.java:587)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication.getSession(SpnegoAuthentication.java:236)
	at com.facebook.airlift.http.client.spnego.SpnegoAuthentication$1.authenticate(SpnegoAuthentication.java:141)
	... 41 more
Caused by: KrbException: KrbException: Cannot locate default realm
	at java.security.jgss/sun.security.krb5.Realm.getDefault(Realm.java:66)
	at java.security.jgss/sun.security.krb5.PrincipalName.<init>(PrincipalName.java:479)
	at java.security.jgss/sun.security.krb5.PrincipalName.<init>(PrincipalName.java:489)
	at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:630)
	... 50 more
Caused by: KrbException: Cannot locate default realm
	at java.security.jgss/sun.security.krb5.Config.getDefaultRealm(Config.java:1219)
	at java.security.jgss/sun.security.krb5.Realm.getDefault(Realm.java:62)
	... 53 more

Can you do some testing as to why this was an UncheckedIOException before ? I suspect the call flow has changed, and it would be good to know why

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I could see the CI is passing before merging #128. So I suspect the issue has been brought in by the same.

Upgrading jetty from 12.0.18 to 12.1.1 has introduced changes in some threading / async I guess.

@mehradpk

Copy link
Copy Markdown

FYI.

Test case failure caused by an upstream Jetty behavior change -

The change came as part of jetty 12.0.19 release. Jetty team found a bug jetty/jetty.project#12916 where InputStreamResponseListener remains open in case of errors/exceptions, so as part of refactoring they also changed the behaviour of wrapping RuntimeException as IOException. Now, RuntimeException is re-thrown as it is without wrapping.

jetty/jetty.project#12931

if(failure != null)
    throw IO.rethrow(failure); 

UncheckedIOException wraps IOException in airlift - StringResponseHandler.handle()

catch (IOException e) {
     throw new UncheckedIOException(e);
}

thus earlier the test case was passing but post this change RuntimeException is directly thrown leads to test case failure.

As a fix, the expected exception is changed from IOException to RuntimeException.

@nishithakbhaskaran

Copy link
Copy Markdown
Author

@mehradpk @aaneja Can I go ahead and close this PR since the fix has been already added in #132 with downgraded jetty version?

@aaneja

aaneja commented Nov 17, 2025

Copy link
Copy Markdown

@mehradpk @aaneja Can I go ahead and close this PR since the fix has been already added in #132 with downgraded jetty version?

Sure

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.

3 participants