aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
index 5bdc8ab6..367d4ab9 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedUebTopicSourceFactory.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.SingleThreadedUebTopicSource;
@@ -37,6 +38,7 @@ import org.slf4j.LoggerFactory;
* Factory of UEB Source Topics indexed by topic name.
*/
class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
+ private static final Pattern COMMA_SPACE_PAT = Pattern.compile("\\s*,\\s*");
private static final String MISSING_TOPIC = "A topic must be provided";
/**
@@ -64,7 +66,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
return uebTopicSources.get(busTopicParams.getTopic());
}
- UebTopicSource uebTopicSource = makeSource(busTopicParams);
+ var uebTopicSource = makeSource(busTopicParams);
if (busTopicParams.isManaged()) {
uebTopicSources.put(busTopicParams.getTopic(), uebTopicSource);
@@ -85,7 +87,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
List<UebTopicSource> newUebTopicSources = new ArrayList<>();
synchronized (this) {
- for (String topic : readTopics.split("\\s*,\\s*")) {
+ for (String topic : COMMA_SPACE_PAT.split(readTopics)) {
addTopic(newUebTopicSources, topic, properties);
}
}
@@ -120,7 +122,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
String topicPrefix = PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS + "." + topic;
- PropertyUtils props = new PropertyUtils(properties, topicPrefix,
+ var props = new PropertyUtils(properties, topicPrefix,
(name, value, ex) -> logger.warn("{}: {} {} is in invalid format for topic {} ", this, name, value, topic));
String servers = properties.getProperty(topicPrefix + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX);
@@ -129,7 +131,7 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
return;
}
- UebTopicSource uebTopicSource = this.build(UebPropertyUtils.makeBuilder(props, topic, servers)
+ var uebTopicSource = this.build(UebPropertyUtils.makeBuilder(props, topic, servers)
.consumerGroup(props.getString(
PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, null))
.consumerInstance(props.getString(
@@ -209,8 +211,6 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("IndexedUebTopicSourceFactory []");
- return builder.toString();
+ return "IndexedUebTopicSourceFactory []";
}
}