Skip to content

Commit dd05307

Browse files
committed
Polish "Calculate hashCode only once in ConfigurationPropertyName"
See gh-21394
1 parent c9f6a12 commit dd05307

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
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;
2827

2928
import static org.assertj.core.api.Assertions.assertThat;
3029
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -621,11 +620,10 @@ void isValidWhenNotValidShouldReturnFalse() {
621620
}
622621

623622
@Test
624-
void hashCodeIsOnlyCalculatedOnce() {
623+
void hashCodeIsStored() {
625624
ConfigurationPropertyName name = ConfigurationPropertyName.of("hash.code");
626625
int hashCode = name.hashCode();
627-
int hashCodeField = (int) ReflectionTestUtils.getField(name, "hashCode");
628-
assertThat(hashCodeField).isEqualTo(hashCode);
626+
assertThat(name).hasFieldOrPropertyWithValue("hashCode", hashCode);
629627
}
630628

631629
}

0 commit comments

Comments
 (0)