On Sat, 30 Apr 2022 10:17:43 GMT, Andrey Turbanov <aturba...@openjdk.org> wrote:
> `AuthenticationInfo.requestAuthentication` uses separate `HashMap`'s `get` > +`put` calls. > > https://github.com/openjdk/jdk/blob/176bb23de18d9ab448e77e85a9c965a7c02f2c50/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java#L155-L165 > > Instead we can use the `HashMap.putIfAbsent` to make code a bit easier to > follow. We know that `requests` can contain only non-null values. src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java line 159: > 157: if (t == null || t == c) { > 158: assert cached == null; > 159: return cached; Hello Andrey, while you are in this code, I think changing these 2 lines: assert cached == null; return cached; to just: return null; would be better. There's already a `if (cached != null) return cached;` code, a few lines above and after that line there's no other modifications to this `cached` local variable, so changing this line to just return null would remove any confusion while reading this code. ------------- PR: https://git.openjdk.java.net/jdk/pull/8484