8301492: Modernize equals() method of ResourceBundle.CacheKey and Bundles.CacheKey

Reviewed-by: prappo, naoto
This commit is contained in:
Sergey Tsypanov 2023-06-26 19:41:43 +00:00 committed by Pavel Rappo
parent a08352f621
commit 297c799631
2 changed files with 3 additions and 7 deletions

View file

@ -719,8 +719,7 @@ public abstract class ResourceBundle {
if (this == other) {
return true;
}
try {
final CacheKey otherEntry = (CacheKey)other;
if (other instanceof CacheKey otherEntry) {
//quick check to see if they are not equal
if (modulesHash != otherEntry.modulesHash) {
return false;
@ -738,7 +737,6 @@ public abstract class ResourceBundle {
Module caller = getCallerModule();
return ((module != null) && (module.equals(otherEntry.getModule())) &&
(caller != null) && (caller.equals(otherEntry.getCallerModule())));
} catch (NullPointerException | ClassCastException e) {
}
return false;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -502,15 +502,13 @@ public abstract class Bundles {
if (this == other) {
return true;
}
try {
final CacheKey otherEntry = (CacheKey)other;
if (other instanceof CacheKey otherEntry) {
//quick check to see if they are not equal
if (hashCodeCache != otherEntry.hashCodeCache) {
return false;
}
return locale.equals(otherEntry.locale)
&& name.equals(otherEntry.name);
} catch (NullPointerException | ClassCastException e) {
}
return false;
}