Commit 83f179e8c776e205cfdc4e15c06f6fd4f1473bee
Committed by
mp-loki
1 parent
3aeafecf
Fixed bug with REST API data representation for telemetry plugin
Showing
2 changed files
with
6 additions
and
2 deletions
@@ -291,7 +291,6 @@ public class SubscriptionManager { | @@ -291,7 +291,6 @@ public class SubscriptionManager { | ||
291 | } else { | 291 | } else { |
292 | log.trace("[{}] Remote subscription is now handled on new server address: [{}]", s.getWsSessionId(), newAddress); | 292 | log.trace("[{}] Remote subscription is now handled on new server address: [{}]", s.getWsSessionId(), newAddress); |
293 | subscriptionIterator.remove(); | 293 | subscriptionIterator.remove(); |
294 | - | ||
295 | //TODO: onUpdate state of subscription by WsSessionId and other maps. | 294 | //TODO: onUpdate state of subscription by WsSessionId and other maps. |
296 | } | 295 | } |
297 | } | 296 | } |
@@ -139,7 +139,12 @@ public class TelemetryRestMsgHandler extends DefaultRestMsgHandler { | @@ -139,7 +139,12 @@ public class TelemetryRestMsgHandler extends DefaultRestMsgHandler { | ||
139 | public void onSuccess(PluginContext ctx, List<TsKvEntry> data) { | 139 | public void onSuccess(PluginContext ctx, List<TsKvEntry> data) { |
140 | Map<String, List<TsData>> result = new LinkedHashMap<>(); | 140 | Map<String, List<TsData>> result = new LinkedHashMap<>(); |
141 | for (TsKvEntry entry : data) { | 141 | for (TsKvEntry entry : data) { |
142 | - result.put(entry.getKey(), data.stream().map(v -> new TsData(v.getTs(), v.getValueAsString())).collect(Collectors.toList())); | 142 | + List<TsData> vList = result.get(entry.getKey()); |
143 | + if (vList == null) { | ||
144 | + vList = new ArrayList<>(); | ||
145 | + result.put(entry.getKey(), vList); | ||
146 | + } | ||
147 | + vList.add(new TsData(entry.getTs(), entry.getValueAsString())); | ||
143 | } | 148 | } |
144 | msg.getResponseHolder().setResult(new ResponseEntity<>(result, HttpStatus.OK)); | 149 | msg.getResponseHolder().setResult(new ResponseEntity<>(result, HttpStatus.OK)); |
145 | } | 150 | } |