Use Objects.equals() instead (#1452)

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
Yanming Zhou
2025-01-22 04:29:20 +08:00
committed by GitHub
parent f4e078ad03
commit e7aa45e88e

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -139,7 +140,7 @@ public abstract class ContextRefresher {
if (!after.containsKey(key)) {
result.put(key, null);
}
else if (!equal(before.get(key), after.get(key))) {
else if (!Objects.equals(before.get(key), after.get(key))) {
result.put(key, after.get(key));
}
}
@@ -151,16 +152,6 @@ public abstract class ContextRefresher {
return result;
}
private boolean equal(Object one, Object two) {
if (one == null && two == null) {
return true;
}
if (one == null || two == null) {
return false;
}
return one.equals(two);
}
private Map<String, Object> extract(MutablePropertySources propertySources) {
Map<String, Object> result = new HashMap<>();
List<PropertySource<?>> sources = new ArrayList<>();