Skip to content

Commit a6efe77

Browse files
committed
Polish "Calculate hashCode only once in ConfigurationPropertyName"
See gh-21394
1 parent 46f3534 commit a6efe77

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.junit.jupiter.api.Test;
2525

2626
import org.springframework.boot.context.properties.source.ConfigurationPropertyName.Form;
27+
import org.springframework.test.util.ReflectionTestUtils;
2728

2829
import static org.assertj.core.api.Assertions.assertThat;
2930
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -623,7 +624,8 @@ void isValidWhenNotValidShouldReturnFalse() {
623624
void hashCodeIsStored() {
624625
ConfigurationPropertyName name = ConfigurationPropertyName.of("hash.code");
625626
int hashCode = name.hashCode();
626-
assertThat(name).hasFieldOrPropertyWithValue("hashCode", hashCode);
627+
// hasFieldOrPropertyWithValue would lookup for `hashCode()`.
628+
assertThat(ReflectionTestUtils.getField(name, "hashCode")).isEqualTo(hashCode);
627629
}
628630

629631
}

0 commit comments

Comments
 (0)