Browse Source

Merge branch '2.1.x'

pull/15496/head
Stephane Nicoll 7 years ago
parent
commit
317c4c2c38
  1. 18
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java
  2. 7
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/StringSequenceTests.java

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

@ -111,20 +111,20 @@ final class StringSequence implements CharSequence { @@ -111,20 +111,20 @@ final class StringSequence implements CharSequence {
if (this == obj) {
return true;
}
if (obj == null || !CharSequence.class.isInstance(obj)) {
if (!(obj instanceof CharSequence)) {
return false;
}
CharSequence other = (CharSequence) obj;
int n = length();
if (n == other.length()) {
int i = 0;
while (n-- != 0) {
if (charAt(i) != other.charAt(i)) {
return false;
}
i++;
if (n != other.length()) {
return false;
}
int i = 0;
while (n-- != 0) {
if (charAt(i) != other.charAt(i)) {
return false;
}
return true;
i++;
}
return true;
}

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

@ -162,6 +162,13 @@ public class StringSequenceTests { @@ -162,6 +162,13 @@ public class StringSequenceTests {
assertThat(a).isEqualTo(b).isNotEqualTo(c);
}
@Test
public void notEqualsWhenSequencesOfDifferentLength() {
StringSequence a = new StringSequence("abcd");
StringSequence b = new StringSequence("ef");
assertThat(a).isNotEqualTo(b);
}
@Test
public void startsWithWhenExactMatch() {
assertThat(new StringSequence("abc").startsWith("abc")).isTrue();

Loading…
Cancel
Save