Skip to content

Commit c0b07a9

Browse files
committed
Polish "Fix StringSequence.equals() for different lengths"
Closes gh-15465
1 parent 2a0680c commit c0b07a9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ public boolean equals(Object obj) {
111111
if (this == obj) {
112112
return true;
113113
}
114-
if (obj == null || !CharSequence.class.isInstance(obj)) {
114+
if (!(obj instanceof CharSequence)) {
115115
return false;
116116
}
117117
CharSequence other = (CharSequence) obj;
118118
int n = length();
119-
if (n == other.length()) {
120-
int i = 0;
121-
while (n-- != 0) {
122-
if (charAt(i) != other.charAt(i)) {
123-
return false;
124-
}
125-
i++;
119+
if (n != other.length()) {
120+
return false;
121+
}
122+
int i = 0;
123+
while (n-- != 0) {
124+
if (charAt(i) != other.charAt(i)) {
125+
return false;
126126
}
127-
return true;
127+
i++;
128128
}
129-
return false;
129+
return true;
130130
}
131131

132132
@Override

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/StringSequenceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 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.

0 commit comments

Comments
 (0)