SolrMetricManager.registerMetric trivial opt

Needn't check for existing metric prior to removing.
(code-reviewed by ab@apache.org)
This commit is contained in:
David Smiley 2020-04-20 11:44:44 -04:00 committed by GitHub
parent 89e14faca9
commit 37ad0e552d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -702,8 +702,8 @@ public class SolrMetricManager {
if (context != null) {
context.registerMetricName(fullName);
}
synchronized (metricRegistry) {
if (force && metricRegistry.getMetrics().containsKey(fullName)) {
synchronized (metricRegistry) { // prevent race; register() throws if metric is already present
if (force) { // must remove any existing one if present
metricRegistry.remove(fullName);
}
metricRegistry.register(fullName, metric);