bbotella commented on code in PR #239: URL: https://github.com/apache/cassandra-sidecar/pull/239#discussion_r2241192913
########## server/src/main/java/org/apache/cassandra/sidecar/cluster/locator/CachedLocalTokenRanges.java: ########## @@ -205,22 +205,26 @@ private synchronized Map<Integer, Set<TokenRange>> getCacheOrReload(Metadata met if (isClusterTheSame && localTokenRangesCache != null && localTokenRangesCache.containsKey(ks.getName())) { // we don't need to rebuild if already cached - perKeyspaceBuilder.put(ks.getName(), localTokenRangesCache.get(ks.getName())); + Map<Integer, Set<TokenRange>> cachedRanges = localTokenRangesCache.get(ks.getName()); + if (cachedRanges != null) + { + perKeyspaceBuilder.put(ks.getName(), cachedRanges); + continue; + } } - else + + // Build token ranges for this keyspace + ImmutableMap.Builder<Integer, Set<TokenRange>> resultBuilder = ImmutableMap.builder(); + for (InstanceMetadata instance : localInstances) { - ImmutableMap.Builder<Integer, Set<TokenRange>> resultBuilder = ImmutableMap.builder(); - for (InstanceMetadata instance : localInstances) + Pair<Host, Set<TokenRange>> pair = tokenRangesOfHost(metadata, keyspace, instance, allHosts); + if (pair != null) { - Pair<Host, Set<TokenRange>> pair = tokenRangesOfHost(metadata, keyspace, instance, allHosts); - if (pair != null) - { - hostBuilder.add(pair.getKey()); - resultBuilder.put(instance.id(), Collections.unmodifiableSet(pair.getValue())); - } + hostBuilder.add(pair.getKey()); + resultBuilder.put(instance.id(), Collections.unmodifiableSet(pair.getValue())); } - perKeyspaceBuilder.put(ks.getName(), resultBuilder.build()); Review Comment: Spotbug was complaining about this -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org