Merge pull request #21394 from dreis2211

* pr/21394:
  Polish "Calculate hashCode only once in ConfigurationPropertyName"
  Calculate hashCode only once in ConfigurationPropertyName

Closes gh-21394
This commit is contained in:
Stephane Nicoll 2020-05-12 10:16:18 +02:00
commit 46f353461b
2 changed files with 8 additions and 0 deletions

View File

@ -444,6 +444,7 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
} }
hashCode = 31 * hashCode + elementHashCode; hashCode = 31 * hashCode + elementHashCode;
} }
this.hashCode = hashCode;
} }
return hashCode; return hashCode;
} }

View File

@ -619,4 +619,11 @@ class ConfigurationPropertyNameTests {
assertThat(ConfigurationPropertyName.isValid("foo!bar")).isFalse(); assertThat(ConfigurationPropertyName.isValid("foo!bar")).isFalse();
} }
@Test
void hashCodeIsStored() {
ConfigurationPropertyName name = ConfigurationPropertyName.of("hash.code");
int hashCode = name.hashCode();
assertThat(name).hasFieldOrPropertyWithValue("hashCode", hashCode);
}
} }