Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null pointer exception when attempting to read a system property #245

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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