|
1 | 1 | /* |
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * 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 |
58 | 58 | @java.io.Serial |
59 | 59 | static final long serialVersionUID = -2588378268010453259L; |
60 | 60 |
|
61 | | - // Constants saying what kind of authroization this is. This determines |
| 61 | + // Constants saying what kind of authorization this is. This determines |
62 | 62 | // the namespace in the hash table lookup. |
63 | 63 | public static final char SERVER_AUTHENTICATION = 's'; |
64 | 64 | public static final char PROXY_AUTHENTICATION = 'p'; |
@@ -152,16 +152,10 @@ private static AuthenticationInfo requestAuthentication(String key, Function<Str |
152 | 152 |
|
153 | 153 | // Otherwise, if no request is in progress, record this |
154 | 154 | // 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; |
165 | 159 | } |
166 | 160 | // Otherwise, an other thread is currently performing authentication: |
167 | 161 | // wait until it finishes. |
|
0 commit comments