yifan-c commented on code in PR #263:
URL: https://github.com/apache/cassandra-sidecar/pull/263#discussion_r2388594720
##########
server/src/main/java/org/apache/cassandra/sidecar/metrics/FilteringMetricRegistry.java:
##########
@@ -283,15 +284,22 @@ private <T extends Metric> T typeChecked(Metric metric,
Class<T> type)
*/
private Metric addExcludedMetricIfNotExists(String name, Function<String,
? extends Metric> mappingFunction)
{
- return excludedMetrics.computeIfAbsent(name, k -> {
+ AtomicBoolean registeredExcludedMetric = new AtomicBoolean(false);
+ Metric excludedMetric = excludedMetrics.computeIfAbsent(name, k -> {
+ registeredExcludedMetric.set(true);
+ return mappingFunction.apply(k);
+ });
+
+ if (registeredExcludedMetric.get())
+ {
// allMetrics needs to be recomputed when an excluded metric is
registered
synchronized (this)
{
allMetrics = null;
}
+ }
Review Comment:
Now the update sequence looks correct. W/o the patch, it is possible that
`allMetrics` is updated _before_ `excludedMetric`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]