This is an automated email from the ASF dual-hosted git repository. jackie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push: new 3c2b100742 validate DropwizardMetricName equals (#12559) 3c2b100742 is described below commit 3c2b1007425ef0f6e69d35280efce17f12e6ba10 Author: sullis <git...@seansullivan.com> AuthorDate: Wed Mar 6 09:19:50 2024 -0800 validate DropwizardMetricName equals (#12559) --- .../metrics/dropwizard/DropwizardMetricName.java | 7 ++--- .../dropwizard/DropwizardMetricNameTest.java | 31 ++++++++++++++++++++++ pinot-plugins/pom.xml | 5 ++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/pinot-plugins/pinot-metrics/pinot-dropwizard/src/main/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricName.java b/pinot-plugins/pinot-metrics/pinot-dropwizard/src/main/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricName.java index ebd38f7ba0..ba51ffa9bb 100644 --- a/pinot-plugins/pinot-metrics/pinot-dropwizard/src/main/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricName.java +++ b/pinot-plugins/pinot-metrics/pinot-dropwizard/src/main/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricName.java @@ -18,10 +18,11 @@ */ package org.apache.pinot.plugin.metrics.dropwizard; +import java.util.Objects; import org.apache.pinot.spi.metrics.PinotMetricName; -public class DropwizardMetricName implements PinotMetricName { +public final class DropwizardMetricName implements PinotMetricName { private final String _metricName; public DropwizardMetricName(Class<?> klass, String name) { @@ -49,7 +50,7 @@ public class DropwizardMetricName implements PinotMetricName { return false; } DropwizardMetricName that = (DropwizardMetricName) obj; - return _metricName.equals(that._metricName); + return Objects.equals(_metricName, that._metricName); } /** @@ -57,7 +58,7 @@ public class DropwizardMetricName implements PinotMetricName { */ @Override public int hashCode() { - return _metricName.hashCode(); + return Objects.hashCode(_metricName); } @Override diff --git a/pinot-plugins/pinot-metrics/pinot-dropwizard/src/test/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricNameTest.java b/pinot-plugins/pinot-metrics/pinot-dropwizard/src/test/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricNameTest.java new file mode 100644 index 0000000000..e2015c3a07 --- /dev/null +++ b/pinot-plugins/pinot-metrics/pinot-dropwizard/src/test/java/org/apache/pinot/plugin/metrics/dropwizard/DropwizardMetricNameTest.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.pinot.plugin.metrics.dropwizard; + +import nl.jqno.equalsverifier.EqualsVerifier; +import org.testng.annotations.Test; + + +public class DropwizardMetricNameTest { + @Test + public void testEqualsContract() { + EqualsVerifier.forClass(DropwizardMetricName.class).verify(); + } +} diff --git a/pinot-plugins/pom.xml b/pinot-plugins/pom.xml index a1edbed934..57e66ca0fd 100644 --- a/pinot-plugins/pom.xml +++ b/pinot-plugins/pom.xml @@ -64,6 +64,11 @@ <artifactId>testng</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>nl.jqno.equalsverifier</groupId> + <artifactId>equalsverifier</artifactId> + <scope>test</scope> + </dependency> </dependencies> <profiles> <profile> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org