Skip to content

Commit

Permalink
fixed shard statistics namespace grouping (was broken for thing names…
Browse files Browse the repository at this point in the history
… containing a ":")

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Nov 4, 2020
1 parent 1870420 commit 8ceb7b1
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,13 @@ public CompletionStage<RetrieveStatisticsDetailsResponse> 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);
Expand Down

0 comments on commit 8ceb7b1

Please sign in to comment.