getCacheBeans() {
-@@ -60,7 +60,7 @@ public class JCacheGaugeSet implements MetricSet {
- return ManagementFactory.getPlatformMBeanServer()
- .queryMBeans(ObjectName.getInstance(M_BEAN_COORDINATES), null);
- } catch (MalformedObjectNameException e) {
-- LOGGER.error("Unable to retrieve {}. Are JCache statistics enabled?", M_BEAN_COORDINATES);
-+ LOG.error("Unable to retrieve {}. Are JCache statistics enabled?", M_BEAN_COORDINATES);
- throw new RuntimeException(e);
- }
- }
--- a/metrics-jcache/src/test/java/JCacheGaugeSetTest.java
+++ b/metrics-jcache/src/test/java/JCacheGaugeSetTest.java
@@ -11,7 +11,7 @@ import org.junit.jupiter.api.AfterEach;
@@ -8461,11 +8339,11 @@
private static final char[] QUOTABLE_CHARS = new char[] {',', '=', ':', '"'};
- private static final Logger LOGGER = LoggerFactory.getLogger(JmxReporter.class);
-+ private static final Logger LOG = LoggerFactory.getLogger(DefaultObjectNameFactory.class);
++ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultObjectNameFactory.class);
@Override
public ObjectName createName(String type, String domain, MetricName name) {
-@@ -38,14 +38,13 @@ public class DefaultObjectNameFactory implements ObjectNameFactory {
+@@ -38,9 +38,8 @@ public class DefaultObjectNameFactory implements ObjectNameFactory {
|| shouldQuote(objectName.getKeyProperty("type"))) {
properties.put("type", ObjectName.quote(type));
}
@@ -8476,12 +8354,6 @@
} catch (MalformedObjectNameException e) {
try {
return new ObjectName(domain, "name", ObjectName.quote(name.getKey()));
- } catch (MalformedObjectNameException e1) {
-- LOGGER.warn("Unable to register {} {}", type, name, e1);
-+ LOG.warn("Unable to register {} {}", type, name, e1);
- throw new RuntimeException(e1);
- }
- }
--- a/metrics-jmx/src/main/java/io/dropwizard/metrics5/jmx/JmxReporter.java
+++ b/metrics-jmx/src/main/java/io/dropwizard/metrics5/jmx/JmxReporter.java
@@ -1,5 +1,9 @@
@@ -8542,147 +8414,6 @@
return this;
}
-@@ -159,7 +160,7 @@ public class JmxReporter implements Reporter, Closeable {
- }
- }
-
-- private static final Logger LOGGER = LoggerFactory.getLogger(JmxReporter.class);
-+ private static final Logger LOG = LoggerFactory.getLogger(JmxReporter.class);
-
- @SuppressWarnings("UnusedDeclaration")
- public interface MetricMBean {
-@@ -570,9 +571,9 @@ public class JmxReporter implements Reporter, Closeable {
- registerMBean(new JmxGauge(gauge, objectName), objectName);
- }
- } catch (InstanceAlreadyExistsException e) {
-- LOGGER.debug("Unable to register gauge", e);
-+ LOG.debug("Unable to register gauge", e);
- } catch (JMException e) {
-- LOGGER.warn("Unable to register gauge", e);
-+ LOG.warn("Unable to register gauge", e);
- }
- }
-
-@@ -582,9 +583,9 @@ public class JmxReporter implements Reporter, Closeable {
- final ObjectName objectName = createName("gauges", name);
- unregisterMBean(objectName);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister gauge", e);
-+ LOG.debug("Unable to unregister gauge", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister gauge", e);
-+ LOG.warn("Unable to unregister gauge", e);
- }
- }
-
-@@ -596,9 +597,9 @@ public class JmxReporter implements Reporter, Closeable {
- registerMBean(new JmxCounter(counter, objectName), objectName);
- }
- } catch (InstanceAlreadyExistsException e) {
-- LOGGER.debug("Unable to register counter", e);
-+ LOG.debug("Unable to register counter", e);
- } catch (JMException e) {
-- LOGGER.warn("Unable to register counter", e);
-+ LOG.warn("Unable to register counter", e);
- }
- }
-
-@@ -608,9 +609,9 @@ public class JmxReporter implements Reporter, Closeable {
- final ObjectName objectName = createName("counters", name);
- unregisterMBean(objectName);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister counter", e);
-+ LOG.debug("Unable to unregister counter", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister counter", e);
-+ LOG.warn("Unable to unregister counter", e);
- }
- }
-
-@@ -622,9 +623,9 @@ public class JmxReporter implements Reporter, Closeable {
- registerMBean(new JmxHistogram(histogram, objectName), objectName);
- }
- } catch (InstanceAlreadyExistsException e) {
-- LOGGER.debug("Unable to register histogram", e);
-+ LOG.debug("Unable to register histogram", e);
- } catch (JMException e) {
-- LOGGER.warn("Unable to register histogram", e);
-+ LOG.warn("Unable to register histogram", e);
- }
- }
-
-@@ -634,9 +635,9 @@ public class JmxReporter implements Reporter, Closeable {
- final ObjectName objectName = createName("histograms", name);
- unregisterMBean(objectName);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister histogram", e);
-+ LOG.debug("Unable to unregister histogram", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister histogram", e);
-+ LOG.warn("Unable to unregister histogram", e);
- }
- }
-
-@@ -649,9 +650,9 @@ public class JmxReporter implements Reporter, Closeable {
- new JmxMeter(meter, objectName, timeUnits.rateFor(name.getKey())), objectName);
- }
- } catch (InstanceAlreadyExistsException e) {
-- LOGGER.debug("Unable to register meter", e);
-+ LOG.debug("Unable to register meter", e);
- } catch (JMException e) {
-- LOGGER.warn("Unable to register meter", e);
-+ LOG.warn("Unable to register meter", e);
- }
- }
-
-@@ -661,9 +662,9 @@ public class JmxReporter implements Reporter, Closeable {
- final ObjectName objectName = createName("meters", name);
- unregisterMBean(objectName);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister meter", e);
-+ LOG.debug("Unable to unregister meter", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister meter", e);
-+ LOG.warn("Unable to unregister meter", e);
- }
- }
-
-@@ -681,9 +682,9 @@ public class JmxReporter implements Reporter, Closeable {
- objectName);
- }
- } catch (InstanceAlreadyExistsException e) {
-- LOGGER.debug("Unable to register timer", e);
-+ LOG.debug("Unable to register timer", e);
- } catch (JMException e) {
-- LOGGER.warn("Unable to register timer", e);
-+ LOG.warn("Unable to register timer", e);
- }
- }
-
-@@ -693,9 +694,9 @@ public class JmxReporter implements Reporter, Closeable {
- final ObjectName objectName = createName("timers", name);
- unregisterMBean(objectName);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister timer", e);
-+ LOG.debug("Unable to unregister timer", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister timer", e);
-+ LOG.warn("Unable to unregister timer", e);
- }
- }
-
-@@ -708,9 +709,9 @@ public class JmxReporter implements Reporter, Closeable {
- try {
- unregisterMBean(name);
- } catch (InstanceNotFoundException e) {
-- LOGGER.debug("Unable to unregister metric", e);
-+ LOG.debug("Unable to unregister metric", e);
- } catch (MBeanRegistrationException e) {
-- LOGGER.warn("Unable to unregister metric", e);
-+ LOG.warn("Unable to unregister metric", e);
- }
- }
- registered.clear();
--- a/metrics-jmx/src/test/java/io/dropwizard/metrics5/jmx/DefaultObjectNameFactoryTest.java
+++ b/metrics-jmx/src/test/java/io/dropwizard/metrics5/jmx/DefaultObjectNameFactoryTest.java
@@ -7,7 +7,7 @@ import io.dropwizard.metrics5.MetricName;
@@ -9002,21 +8733,7 @@
import java.util.HashMap;
import java.util.Map;
import javax.management.JMException;
-@@ -19,7 +20,7 @@ import org.slf4j.LoggerFactory;
- * These JMX objects are only available on Java 7 and above.
- */
- public class BufferPoolMetricSet implements MetricSet {
-- private static final Logger LOGGER = LoggerFactory.getLogger(BufferPoolMetricSet.class);
-+ private static final Logger LOG = LoggerFactory.getLogger(BufferPoolMetricSet.class);
- private static final String[] ATTRIBUTES = {"Count", "MemoryUsed", "TotalCapacity"};
- private static final String[] NAMES = {"count", "used", "capacity"};
- private static final String[] POOLS = {"direct", "mapped"};
-@@ -43,10 +44,10 @@ public class BufferPoolMetricSet implements MetricSet {
- gauges.put(
- MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServer, on, attribute));
- } catch (JMException ignored) {
-- LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6");
-+ LOG.debug("Unable to load buffer pool MBeans, possibly running on Java 6");
+@@ -47,6 +48,6 @@ public class BufferPoolMetricSet implements MetricSet {
}
}
}
diff --git a/integration-tests/metrics-expected-warnings.txt b/integration-tests/metrics-expected-warnings.txt
index 401c709f..61810502 100644
--- a/integration-tests/metrics-expected-warnings.txt
+++ b/integration-tests/metrics-expected-warnings.txt
@@ -9,9 +9,9 @@ metrics-collectd/src/main/java/io/dropwizard/metrics5/collectd/PacketWriter.java
metrics-core/src/main/java/io/dropwizard/metrics5/CsvReporter.java:[390,35] [FormatStringConcatenation] Defer string concatenation to the invoked method
metrics-core/src/main/java/io/dropwizard/metrics5/InstrumentedExecutorService.java:[244,25] [try] auto-closeable resource durationContext is never referenced in body of corresponding try statement
metrics-core/src/main/java/io/dropwizard/metrics5/InstrumentedExecutorService.java:[266,25] [try] auto-closeable resource context is never referenced in body of corresponding try statement
-metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[431,14] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
-metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[436,16] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
-metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[449,17] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
+metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[431,17] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
+metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[436,19] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
+metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteReporter.java:[449,20] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
metrics-healthchecks/src/test/java/io/dropwizard/metrics5/health/HealthCheckTest.java:[189,46] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone
metrics-healthchecks/src/test/java/io/dropwizard/metrics5/health/HealthCheckTest.java:[203,46] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone
metrics-httpclient/src/test/java/io/dropwizard/metrics5/httpclient/HttpClientMetricNameStrategiesTest.java:[124,22] [deprecation] rewriteURI(URI,HttpHost,boolean) in URIUtils has been deprecated
@@ -26,8 +26,8 @@ metrics-httpclient5/src/main/java/io/dropwizard/metrics5/httpclient5/Instrumente
metrics-httpclient5/src/main/java/io/dropwizard/metrics5/httpclient5/InstrumentedHttpRequestExecutor.java:[49,4] [deprecation] HttpRequestExecutor(Timeout,ConnectionReuseStrategy,Http1StreamListener) in HttpRequestExecutor has been deprecated
metrics-httpclient5/src/test/java/io/dropwizard/metrics5/httpclient5/InstrumentedHttpClientsTest.java:[46,10] [deprecation] execute(ClassicHttpRequest) in HttpClient has been deprecated
metrics-httpclient5/src/test/java/io/dropwizard/metrics5/httpclient5/InstrumentedHttpClientsTest.java:[68,12] [deprecation] execute(ClassicHttpRequest) in HttpClient has been deprecated
-metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbReporter.java:[282,14] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
-metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbReporter.java:[287,16] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
+metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbReporter.java:[282,17] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
+metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbReporter.java:[287,19] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s)
metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics5/servlets/HealthCheckServletTest.java:[31,67] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone
metrics-jdbi3/src/test/java/io/dropwizard/metrics5/jdbi3/strategies/SmartNameStrategyTest.java:[18,10] [deprecation] InstrumentedTimingCollector in io.dropwizard.metrics5.jdbi3 has been deprecated
metrics-jdbi3/src/test/java/io/dropwizard/metrics5/jdbi3/strategies/SmartNameStrategyTest.java:[24,20] [deprecation] InstrumentedTimingCollector in io.dropwizard.metrics5.jdbi3 has been deprecated
diff --git a/integration-tests/metrics.sh b/integration-tests/metrics.sh
index 812a4a12..229ed79e 100755
--- a/integration-tests/metrics.sh
+++ b/integration-tests/metrics.sh
@@ -8,11 +8,7 @@ repository='https://github.com/dropwizard/metrics.git'
revision='v5.0.0-rc22'
additional_build_flags=''
additional_source_directories=''
-# XXX: Minimize the diff by including
-# `-XepOpt:Slf4jLoggerDeclaration:CanonicalStaticLoggerName=LOGGER` once such
-# flags are supported in patch mode. See
-# https://github.com/google/error-prone/pull/4699.
-shared_error_prone_flags='-XepExcludedPaths:.*/target/generated-sources/.*'
+shared_error_prone_flags='-XepExcludedPaths:.*/target/generated-sources/.* -XepOpt:Slf4jLoggerDeclaration:CanonicalStaticLoggerName=LOGGER'
patch_error_prone_flags=''
validation_error_prone_flags=''
validation_build_flags=''
diff --git a/pom.xml b/pom.xml
index d6770ffe..abf8077f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -205,8 +205,8 @@
1.1.1
1.11.0
${version.error-prone-orig}
- ${version.error-prone-orig}-picnic-4
- 2.36.0
+ ${version.error-prone-orig}-picnic-1
+ 2.37.0
0.1.28
1.0
17
@@ -1939,9 +1939,7 @@
-XepOpt:NullAway:AssertsEnabled=true
-XepOpt:NullAway:CheckOptionalEmptiness=true
-XepOpt:Nullness:Conservative=false
- -XepOpt:StatementSwitchToExpressionSwitch:EnableAssignmentSwitchConversion=true
-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true
- -XepOpt:StatementSwitchToExpressionSwitch:EnableReturnSwitchConversion=true
${error-prone.patch-args}
${error-prone.self-check-args}
diff --git a/refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/IsEmpty.java b/refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/IsEmpty.java
index d61cd180..dfd3e7f7 100644
--- a/refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/IsEmpty.java
+++ b/refaster-support/src/main/java/tech/picnic/errorprone/refaster/matchers/IsEmpty.java
@@ -118,11 +118,12 @@ public final class IsEmpty implements Matcher {
}
private boolean isEmptyCollectionConstructor(ExpressionTree tree, VisitorState state) {
- if (!(tree instanceof NewClassTree) || !MUTABLE_COLLECTION_TYPE.matches(tree, state)) {
+ if (!(tree instanceof NewClassTree newClassTree)
+ || !MUTABLE_COLLECTION_TYPE.matches(tree, state)) {
return false;
}
- List extends ExpressionTree> arguments = ((NewClassTree) tree).getArguments();
+ List extends ExpressionTree> arguments = newClassTree.getArguments();
if (arguments.stream().allMatch(a -> EMPTY_COLLECTION_CONSTRUCTOR_ARGUMENT.matches(a, state))) {
/*
* This is a default constructor, or a constructor that creates an empty collection using
diff --git a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java
index 99673e20..183a3e50 100644
--- a/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java
+++ b/refaster-test-support/src/main/java/tech/picnic/errorprone/refaster/test/RefasterRuleCollection.java
@@ -6,6 +6,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
import static com.google.errorprone.BugPattern.LinkType.NONE;
import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Comparator.naturalOrder;
import static tech.picnic.errorprone.refaster.runner.Refaster.INCLUDED_RULES_PATTERN_FLAG;
@@ -17,6 +18,7 @@ import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
+import com.google.common.io.Resources;
import com.google.errorprone.BugCheckerRefactoringTestHelper;
import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode;
import com.google.errorprone.BugPattern;
@@ -38,6 +40,9 @@ import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.tree.EndPosTable;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Position;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -124,13 +129,15 @@ public final class RefasterRuleCollection extends BugChecker implements Compilat
*/
public static void validate(Class> clazz) {
String className = clazz.getSimpleName();
+ String inputResource = className + "TestInput.java";
+ String outputResource = className + "TestOutput.java";
BugCheckerRefactoringTestHelper.newInstance(RefasterRuleCollection.class, clazz)
.setArgs(
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"-XepOpt:" + RULE_COLLECTION_FLAG + '=' + className)
- .addInput(className + "TestInput.java")
- .addOutput(className + "TestOutput.java")
+ .addInputLines(inputResource, loadResource(clazz, inputResource))
+ .addOutputLines(outputResource, loadResource(clazz, outputResource))
.doTest(TestMode.TEXT_MATCH);
}
@@ -247,6 +254,15 @@ public final class RefasterRuleCollection extends BugChecker implements Compilat
return value.substring(index + 1);
}
+ private static String loadResource(Class> contextClass, String resource) {
+ URL url = Resources.getResource(contextClass, resource);
+ try {
+ return Resources.toString(url, UTF_8);
+ } catch (IOException e) {
+ throw new UncheckedIOException("Cannot find resource: " + url, e);
+ }
+ }
+
private class UnexpectedMatchReporter extends TreeScanner<@Nullable Void, VisitorState> {
private final ImmutableRangeMap indexedMatches;