8330815: Use pattern matching for instanceof in KeepAliveCache

Reviewed-by: jpai, djelinski
This commit is contained in:
Christoph Langer 2024-04-25 06:53:36 +00:00
parent d43654e573
commit e818ab60a0

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, 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
@ -389,9 +389,9 @@ class KeepAliveKey {
*/
@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)
@ -405,7 +405,7 @@ class KeepAliveKey {
@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();
}
}