From 8ceb7b1fafd5b1906fb8348e1d5943d585991f9b Mon Sep 17 00:00:00 2001 From: Thomas Jaeckle Date: Wed, 4 Nov 2020 15:05:18 +0100 Subject: [PATCH] fixed shard statistics namespace grouping (was broken for thing names containing a ":") Signed-off-by: Thomas Jaeckle --- ...ieveStatisticsDetailsResponseSupplier.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/services/utils/cluster/src/main/java/org/eclipse/ditto/services/utils/cluster/RetrieveStatisticsDetailsResponseSupplier.java b/services/utils/cluster/src/main/java/org/eclipse/ditto/services/utils/cluster/RetrieveStatisticsDetailsResponseSupplier.java index b79a02355a..8f5b813755 100644 --- a/services/utils/cluster/src/main/java/org/eclipse/ditto/services/utils/cluster/RetrieveStatisticsDetailsResponseSupplier.java +++ b/services/utils/cluster/src/main/java/org/eclipse/ditto/services/utils/cluster/RetrieveStatisticsDetailsResponseSupplier.java @@ -88,22 +88,13 @@ public CompletionStage apply(final DittoHeade .flatMap(strSet -> strSet.stream() .map(str -> { // groupKey may be either namespace or resource-type+namespace (in case of concierge) - final String[] groupKeys = str.split(":", 3); + final String[] groupKeys = str.split(":", 2); // assume String.split(String, int) may not return an empty array - switch (groupKeys.length) { - case 0: - // should not happen with Java 8 strings, but just in case - return EMPTY_ID; - case 1: - case 2: - // normal: namespace - return ensureNonemptyString( - groupKeys[0]); - default: - // concierge: resource-type + namespace - return groupKeys[0] + ":" + - groupKeys[1]; + if (groupKeys.length == 0) { + // should not happen with Java 8 strings, but just in case + return EMPTY_ID; } + return ensureNonemptyString(groupKeys[0]); }) ) .collect(stringMapCollector);