Skip to content

Commit 4caf1ef

Browse files
author
Andrey Turbanov
committed
8287390: Cleanup Map usage in AuthenticationInfo.requestAuthentication
Reviewed-by: dfuchs, jpai
1 parent 27ad1d5 commit 4caf1ef

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
5858
@java.io.Serial
5959
static final long serialVersionUID = -2588378268010453259L;
6060

61-
// Constants saying what kind of authroization this is. This determines
61+
// Constants saying what kind of authorization this is. This determines
6262
// the namespace in the hash table lookup.
6363
public static final char SERVER_AUTHENTICATION = 's';
6464
public static final char PROXY_AUTHENTICATION = 'p';
@@ -152,16 +152,10 @@ private static AuthenticationInfo requestAuthentication(String key, Function<Str
152152

153153
// Otherwise, if no request is in progress, record this
154154
// thread as performing authentication and returns null.
155-
Thread t, c;
156-
c = Thread.currentThread();
157-
if ((t = requests.get(key)) == null) {
158-
requests.put (key, c);
159-
assert cached == null;
160-
return cached;
161-
}
162-
if (t == c) {
163-
assert cached == null;
164-
return cached;
155+
Thread c = Thread.currentThread();
156+
Thread t = requests.putIfAbsent(key, c);
157+
if (t == null || t == c) {
158+
return null;
165159
}
166160
// Otherwise, an other thread is currently performing authentication:
167161
// wait until it finishes.

0 commit comments

Comments
 (0)