mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 22:36:20 +00:00
Simplify equality test in IndexShard#sameException
This commit simplifies an equality test in IndexShard#sameException where the messages for two exceptions are being compared. The previous condition first tested logical equality if the left exception is not null, and otherwise tested reference equality. There is a convenience method since JDK 7 for testing equality in this way: Objects#equals. Closes #16025
This commit is contained in:
parent
abc8c02bed
commit
a7185a1d31
@ -25,6 +25,7 @@ import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -715,8 +716,7 @@ public final class IndexService extends AbstractIndexComponent implements IndexC
|
||||
|
||||
private static boolean sameException(Exception left, Exception right) {
|
||||
if (left.getClass() == right.getClass()) {
|
||||
if ((left.getMessage() != null && left.getMessage().equals(right.getMessage()))
|
||||
|| left.getMessage() == right.getMessage()) {
|
||||
if (Objects.equals(left.getMessage(), right.getMessage())) {
|
||||
StackTraceElement[] stackTraceLeft = left.getStackTrace();
|
||||
StackTraceElement[] stackTraceRight = right.getStackTrace();
|
||||
if (stackTraceLeft.length == stackTraceRight.length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user