Skip to content

Commit 8bf49d2

Browse files
Polish some methods
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent 82ac99f commit 8bf49d2

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

cas/src/main/java/org/springframework/security/cas/web/authentication/DefaultServiceAuthenticationDetails.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ public String getServiceUrl() {
7070

7171
@Override
7272
public boolean equals(Object obj) {
73-
if (this == obj) {
73+
if (super.equals(obj)) {
7474
return true;
7575
}
76-
if (!super.equals(obj) || !(obj instanceof DefaultServiceAuthenticationDetails)) {
77-
return false;
76+
if (obj instanceof DefaultServiceAuthenticationDetails that) {
77+
return this.serviceUrl.equals(that.getServiceUrl());
7878
}
79-
ServiceAuthenticationDetails that = (ServiceAuthenticationDetails) obj;
80-
return this.serviceUrl.equals(that.getServiceUrl());
79+
return false;
8180
}
8281

8382
@Override

web/src/main/java/org/springframework/security/web/savedrequest/DefaultSavedRequest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,17 @@ private void addLocale(Locale locale) {
206206
* @since 4.2
207207
*/
208208
private void addParameters(Map<String, String[]> parameters) {
209-
if (!ObjectUtils.isEmpty(parameters)) {
210-
for (String paramName : parameters.keySet()) {
211-
Object paramValues = parameters.get(paramName);
212-
if (paramValues instanceof String[]) {
213-
this.addParameter(paramName, (String[]) paramValues);
214-
}
215-
else {
216-
logger.warn("ServletRequest.getParameterMap() returned non-String array");
217-
}
218-
}
209+
if (ObjectUtils.isEmpty(parameters)) {
210+
return;
219211
}
220-
}
221212

222-
private void addParameter(String name, String[] values) {
223-
this.parameters.put(name, values);
213+
for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
214+
String name = entry.getKey();
215+
String[] values = entry.getValue();
216+
if (values != null) {
217+
this.parameters.put(name, values);
218+
}
219+
}
224220
}
225221

226222
/**

0 commit comments

Comments
 (0)