Skip to content

Commit

Permalink
Merge pull request #2636 from feltonma91/master
Browse files Browse the repository at this point in the history
Fix start failure with Nullpointed exception when Environment contains empty string Key (fix Issue 2631)
  • Loading branch information
nvoxland committed Apr 19, 2022
2 parents 3043786 + 7a37dd3 commit 97e6821
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public int getPrecedence() {

@Override
protected boolean keyMatches(String wantedKey, String storedKey) {
storedKey = storedKey.replaceFirst("^--", "");
storedKey = String.valueOf(storedKey).replaceFirst("^--", "");

if (super.keyMatches(wantedKey, storedKey)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@ protected boolean isValueSet(Object value) {
* @param storedKey the key stored in the map
*/
protected boolean keyMatches(String wantedKey, String storedKey) {
if (storedKey.equalsIgnoreCase(wantedKey)) {
if (wantedKey.equalsIgnoreCase(storedKey)) {
return true;
}

wantedKey = StringUtil.toKabobCase(wantedKey);
if (storedKey.equalsIgnoreCase(wantedKey)) {
if (wantedKey.equalsIgnoreCase(storedKey)) {
return true;
}

wantedKey = wantedKey.replace(".", "-");
if (storedKey.equalsIgnoreCase(wantedKey)) {
if (wantedKey.equalsIgnoreCase(storedKey)) {
return true;
}

//check for everythingSmashedTogether case insensitively
wantedKey = wantedKey.replace("-", "");
if (storedKey.equalsIgnoreCase(wantedKey)) {
if (wantedKey.equalsIgnoreCase(storedKey)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class MapConfigurationValueProviderTest extends Specification {
provider.getProvidedValue("empty-property") == null
}

def "null values count as not set"() {
when:
def provider = new MapConfigurationValueProvider(["null.property": null])

then:
provider.getProvidedValue("null.property") == null
provider.getProvidedValue("null-property") == null
}

@Unroll
def "keyMatches"() {
expect:
Expand All @@ -42,6 +51,7 @@ class MapConfigurationValueProviderTest extends Specification {
"parent.child" | "parent" | false
"upper.kabob" | "UPPER-KABOB" | true
"one.two.three" | "one-two-three" | true
"null-name" | null | false
}

def "changing map values get picked up dispite caching"() {
Expand Down

0 comments on commit 97e6821

Please sign in to comment.