Skip to content

Commit e7aa45e

Browse files
authored
Use Objects.equals() instead (#1452)
Signed-off-by: Yanming Zhou <[email protected]>
1 parent f4e078a commit e7aa45e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import java.util.HashSet;
2323
import java.util.List;
2424
import java.util.Map;
25+
import java.util.Objects;
2526
import java.util.Set;
2627

2728
import org.apache.commons.logging.Log;
@@ -139,7 +140,7 @@ private Map<String, Object> changes(Map<String, Object> before, Map<String, Obje
139140
if (!after.containsKey(key)) {
140141
result.put(key, null);
141142
}
142-
else if (!equal(before.get(key), after.get(key))) {
143+
else if (!Objects.equals(before.get(key), after.get(key))) {
143144
result.put(key, after.get(key));
144145
}
145146
}
@@ -151,16 +152,6 @@ else if (!equal(before.get(key), after.get(key))) {
151152
return result;
152153
}
153154

154-
private boolean equal(Object one, Object two) {
155-
if (one == null && two == null) {
156-
return true;
157-
}
158-
if (one == null || two == null) {
159-
return false;
160-
}
161-
return one.equals(two);
162-
}
163-
164155
private Map<String, Object> extract(MutablePropertySources propertySources) {
165156
Map<String, Object> result = new HashMap<>();
166157
List<PropertySource<?>> sources = new ArrayList<>();

0 commit comments

Comments
 (0)