RFR: 8191169: java/net/Authenticator/B4769350.java failed intermittently

Daniel Fuchs daniel.fuchs at oracle.com
Fri Aug 16 10:58:29 UTC 2019


Hi,

Please find below a fix for:
8191169: java/net/Authenticator/B4769350.java failed intermittently

http://cr.openjdk.java.net/~dfuchs/webrev_8191169/webrev.00/

This test has been observed failing several times in our CI with

java.lang.RuntimeException: Authenticator was called 3 times. Should be: 2
at B4769350.except(B4769350.java:472)
at B4769350.doProxyTests(B4769350.java:438)
at B4769350.runTest(B4769350.java:462)
at B4769350.main(B4769350.java:447)

The test is meant to test the behavior of the
http.auth.serializeRequests system property (false by
default) which tries to limit the number of times a user is
asked for credentials by the HTTP stack: if two threads
attempt concurrently the same request, the user should be
prompted for credentials only once.

Michael suggested the problem could be a race condition
in the AuthenticationInfo code supporting this mechanism.
Two concurrent requests could find the cache empty, but
one of them could complete and populate the cache before
the other one had the chance to observed that a request
was already in progress. This patch should fix the issue.

The changes to the SetAuthenticator are unrelated. Those
are a test bug - but I observed this test failing while
I was testing my AuthenticationInfo fix and it made me
suspicious. The SetAuthenticator issue is that the second
server created by the test managed to bind to the same
port than the previous iteration had been using, and thus
found unexpected matching credentials in the cache.
This happened because the first server's address had
been recorded as "/127.0.0.1:37591" and the second
as "localhost/127.0.0.1:37591" - and string comparison
didn't match. Anyway I didn't want to push my changes
and take the risk of seeing this test fail ;-)

best regards,

-- daniel




More information about the net-dev mailing list