Skip to content

Commit

Permalink
Merge pull request #24 from CDOT-CV/bug/deposit-topic-override
Browse files Browse the repository at this point in the history
Subscription topic override bug fix
  • Loading branch information
drewjj authored Jul 18, 2024
2 parents 3c48cb8 + a8ea78d commit cbeb1e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
<loader.path>${loader.path}</loader.path>
<buildDirectory>${project.build.directory}</buildDirectory>
</systemPropertyVariables>
<environmentVariables>
<SDW_SUBSCRIPTION_TOPIC>testSubscriptionTopic</SDW_SUBSCRIPTION_TOPIC>
</environmentVariables>
</configuration>
<dependencies>
<dependency>
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/jpo/sdw/depositor/DepositorProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.regex.Pattern;

import jakarta.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -12,6 +10,8 @@
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import jakarta.annotation.PostConstruct;

@ConfigurationProperties("sdw")
@PropertySource("classpath:application.properties")
public class DepositorProperties implements EnvironmentAware {
Expand Down Expand Up @@ -66,9 +66,15 @@ void initialize() {
}

if (getSubscriptionTopics() == null || getSubscriptionTopics().length == 0) {
String topics = String.join(",", DEFAULT_SUBSCRIPTION_TOPICS);
logger.info("No Kafka subscription topics specified in configuration, defaulting to {}", topics);
subscriptionTopics = DEFAULT_SUBSCRIPTION_TOPICS;
// get environment variable SDW_SUBSCRIPTION_TOPIC
String topics = System.getenv("SDW_SUBSCRIPTION_TOPIC");
if (topics == null || topics.isEmpty()) {
topics = String.join(",", DEFAULT_SUBSCRIPTION_TOPICS);
logger.info("No Kafka subscription topics specified in configuration, defaulting to {}", topics);
subscriptionTopics = DEFAULT_SUBSCRIPTION_TOPICS;
} else {
subscriptionTopics = topics.split(",");
}
}

if (getApiKey() == null || getApiKey().isEmpty()) {
Expand Down

0 comments on commit cbeb1e0

Please sign in to comment.