|
23 | 23 | import java.net.SocketAddress; |
24 | 24 | import java.net.UnknownHostException; |
25 | 25 | import java.util.ArrayList; |
| 26 | +import java.util.Arrays; |
26 | 27 | import java.util.List; |
27 | | -import java.util.stream.Stream; |
28 | 28 |
|
29 | 29 | /** |
30 | 30 | * Gets current default configuration for {@link BrokerClient.Builder}. Can be overriden with System |
@@ -148,27 +148,16 @@ static short getAdditionalConnectionFlags() { |
148 | 148 | static Tags getTags() { |
149 | 149 | Tags tags = Tags.empty(); |
150 | 150 | try { |
151 | | - Stream<Tag> stream = |
152 | | - conf.getObject("netifi.client.tags") |
153 | | - .entrySet() |
154 | | - .stream() |
155 | | - .map( |
156 | | - e -> { |
157 | | - String key = e.getKey(); |
158 | | - ConfigValue configValue = e.getValue(); |
159 | | - if (configValue.valueType() == ConfigValueType.STRING) { |
160 | | - String value = (String) configValue.unwrapped(); |
161 | | - if (value.isEmpty()) { |
162 | | - throw new IllegalArgumentException("Tag mapping " + key + " is empty"); |
163 | | - } |
164 | | - return Tag.of(key, value); |
165 | | - } |
166 | | - throw new IllegalArgumentException( |
167 | | - "Tag mapping " + key + " is not a string: " + configValue); |
168 | | - }); |
169 | | - tags = Tags.of(stream::iterator); |
170 | | - } catch (ConfigException.Missing m) { |
171 | | - |
| 151 | + Arrays.stream(conf.getString("netifi.client.tags").split(",")) |
| 152 | + .forEach( |
| 153 | + s -> { |
| 154 | + String[] t = s.split(":"); |
| 155 | + Tag tag = Tag.of(t[0], t[1]); |
| 156 | + tags.and(tag); |
| 157 | + }); |
| 158 | + |
| 159 | + } catch (Throwable t) { |
| 160 | + System.err.println("error parsing tags from config: " + t.getMessage()); |
172 | 161 | } |
173 | 162 |
|
174 | 163 | return tags; |
|
0 commit comments