From a6efe77a0c19f935af83abe18cd5171997b881a7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 12 May 2020 13:10:03 +0200 Subject: [PATCH] Polish "Calculate hashCode only once in ConfigurationPropertyName" See gh-21394 --- .../properties/source/ConfigurationPropertyNameTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java index 9887a67bcc..b339ea4af9 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameTests.java @@ -24,6 +24,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.springframework.boot.context.properties.source.ConfigurationPropertyName.Form; +import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -623,7 +624,8 @@ class ConfigurationPropertyNameTests { void hashCodeIsStored() { ConfigurationPropertyName name = ConfigurationPropertyName.of("hash.code"); int hashCode = name.hashCode(); - assertThat(name).hasFieldOrPropertyWithValue("hashCode", hashCode); + // hasFieldOrPropertyWithValue would lookup for `hashCode()`. + assertThat(ReflectionTestUtils.getField(name, "hashCode")).isEqualTo(hashCode); } }