diff --git a/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java b/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java index 5bdd6f2c009..2abb5667b97 100644 --- a/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java +++ b/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -407,9 +407,9 @@ public KeepAliveKey(URL url, Object obj) { */ @Override public boolean equals(Object obj) { - if ((obj instanceof KeepAliveKey) == false) + if (!(obj instanceof KeepAliveKey kae)) return false; - KeepAliveKey kae = (KeepAliveKey)obj; + return host.equals(kae.host) && (port == kae.port) && protocol.equals(kae.protocol) @@ -423,7 +423,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { String str = protocol+host+port; - return this.obj == null? str.hashCode() : + return this.obj == null ? str.hashCode() : str.hashCode() + this.obj.hashCode(); } }