Skip to content

Commit

Permalink
fix: null pointer exception when attempting to read a system property (
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario authored Apr 9, 2024
1 parent f48ecd8 commit e5191e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private char[] buildPassword(String seed) {
}

private String resolveValue(String property) {
if (!hasComputedProperties(property)) {
if (property == null || property.isEmpty() || !hasComputedProperties(property)) {
return property;
}

Expand All @@ -282,7 +282,9 @@ private String resolveValue(String property) {
value = getPropertyFromSystem(systemProperty, value);
}

property = property.replace(PROPERTY_START + rawSystemProperty + PROPERTY_END, value);
if (value != null) {
property = property.replace(PROPERTY_START + rawSystemProperty + PROPERTY_END, value);
}
}

return property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ void testKafkaOutgoingWithSystemProperty() {
assertEquals("platform-system-property", topic);
}

@Test
void testKafkaOutgoingWithSystemPropertyThatDoesNotExist() {
String topic = ccs.getValue("mp.messaging.outgoing.system.not.exist.topic");
assertEquals("${NO_EXIST}", topic);
}

@Test
void testKafkaOutgoingWithNestedSystemProperty() {
String topic = ccs.getValue("mp.messaging.outgoing.nested-properties.topic");
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ nested.property.topic=nested-topic
mp.messaging.outgoing.nested-properties.connector=smallrye-kafka
mp.messaging.outgoing.nested-properties.topic=${NO_EXIST:${nested.property.topic}}

# System queue to test system properties that do not exist
mp.messaging.outgoing.system.not.exist.topic=${NO_EXIST}

# System queue to test properties defined in other keys
custom.property.topic=custom-topic
mp.messaging.incoming.computed.connector=smallrye-kafka
Expand Down

0 comments on commit e5191e4

Please sign in to comment.