mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Upgrade Error Prone 2.36.0 -> 2.37.0 (#1601)
Resolves #1597. See: - https://github.com/google/error-prone/releases/tag/v2.37.0 - https://github.com/google/error-prone/compare/v2.36.0...v2.37.0 - https://github.com/PicnicSupermarket/error-prone/compare/v2.36.0-picnic-4...v2.37.0-picnic-1
This commit is contained in:
committed by
GitHub
parent
99d359c548
commit
726db5ce5b
@@ -1,5 +1,6 @@
|
|||||||
package tech.picnic.errorprone.refasterrules;
|
package tech.picnic.errorprone.refasterrules;
|
||||||
|
|
||||||
|
import com.google.errorprone.VisitorState;
|
||||||
import com.google.errorprone.fixes.SuggestedFix;
|
import com.google.errorprone.fixes.SuggestedFix;
|
||||||
import com.google.errorprone.refaster.annotation.AfterTemplate;
|
import com.google.errorprone.refaster.annotation.AfterTemplate;
|
||||||
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
import com.google.errorprone.refaster.annotation.BeforeTemplate;
|
||||||
@@ -65,16 +66,18 @@ final class SuggestedFixRules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prefer {@link SuggestedFix#swap(Tree, Tree)} over more contrived alternatives. */
|
/**
|
||||||
|
* Prefer {@link SuggestedFix#swap(Tree, Tree, VisitorState)} over more contrived alternatives.
|
||||||
|
*/
|
||||||
static final class SuggestedFixSwap {
|
static final class SuggestedFixSwap {
|
||||||
@BeforeTemplate
|
@BeforeTemplate
|
||||||
SuggestedFix before(Tree tree1, Tree tree2) {
|
SuggestedFix before(Tree tree1, Tree tree2, VisitorState state) {
|
||||||
return SuggestedFix.builder().swap(tree1, tree2).build();
|
return SuggestedFix.builder().swap(tree1, tree2, state).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTemplate
|
@AfterTemplate
|
||||||
SuggestedFix after(Tree tree1, Tree tree2) {
|
SuggestedFix after(Tree tree1, Tree tree2, VisitorState state) {
|
||||||
return SuggestedFix.swap(tree1, tree2);
|
return SuggestedFix.swap(tree1, tree2, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package tech.picnic.errorprone.refasterrules;
|
package tech.picnic.errorprone.refasterrules;
|
||||||
|
|
||||||
|
import com.google.errorprone.VisitorState;
|
||||||
import com.google.errorprone.fixes.SuggestedFix;
|
import com.google.errorprone.fixes.SuggestedFix;
|
||||||
import com.sun.source.tree.ExpressionTree;
|
import com.sun.source.tree.ExpressionTree;
|
||||||
import com.sun.source.tree.Tree;
|
import com.sun.source.tree.Tree;
|
||||||
@@ -23,7 +24,9 @@ final class SuggestedFixRulesTest implements RefasterRuleCollectionTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SuggestedFix testSuggestedFixSwap() {
|
SuggestedFix testSuggestedFixSwap() {
|
||||||
return SuggestedFix.builder().swap((Tree) null, (ExpressionTree) null).build();
|
return SuggestedFix.builder()
|
||||||
|
.swap((Tree) null, (ExpressionTree) null, (VisitorState) null)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
SuggestedFix testSuggestedFixPrefixWith() {
|
SuggestedFix testSuggestedFixPrefixWith() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package tech.picnic.errorprone.refasterrules;
|
package tech.picnic.errorprone.refasterrules;
|
||||||
|
|
||||||
|
import com.google.errorprone.VisitorState;
|
||||||
import com.google.errorprone.fixes.SuggestedFix;
|
import com.google.errorprone.fixes.SuggestedFix;
|
||||||
import com.sun.source.tree.ExpressionTree;
|
import com.sun.source.tree.ExpressionTree;
|
||||||
import com.sun.source.tree.Tree;
|
import com.sun.source.tree.Tree;
|
||||||
@@ -23,7 +24,7 @@ final class SuggestedFixRulesTest implements RefasterRuleCollectionTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SuggestedFix testSuggestedFixSwap() {
|
SuggestedFix testSuggestedFixSwap() {
|
||||||
return SuggestedFix.swap((Tree) null, (ExpressionTree) null);
|
return SuggestedFix.swap((Tree) null, (ExpressionTree) null, (VisitorState) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
SuggestedFix testSuggestedFixPrefixWith() {
|
SuggestedFix testSuggestedFixPrefixWith() {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import java.util.Set;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import javax.lang.model.element.AnnotationMirror;
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
import javax.lang.model.element.AnnotationValue;
|
import javax.lang.model.element.AnnotationValue;
|
||||||
import javax.lang.model.element.Modifier;
|
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
import tech.picnic.errorprone.utils.SourceCode;
|
import tech.picnic.errorprone.utils.SourceCode;
|
||||||
|
|
||||||
@@ -102,7 +101,8 @@ public final class ExhaustiveRefasterTypeMigration extends BugChecker implements
|
|||||||
AnnotationTree migrationAnnotation = migrationAnnotations.onlyMatchingNode();
|
AnnotationTree migrationAnnotation = migrationAnnotations.onlyMatchingNode();
|
||||||
AnnotationMirror annotationMirror = ASTHelpers.getAnnotationMirror(migrationAnnotation);
|
AnnotationMirror annotationMirror = ASTHelpers.getAnnotationMirror(migrationAnnotation);
|
||||||
TypeSymbol migratedType = getMigratedType(annotationMirror);
|
TypeSymbol migratedType = getMigratedType(annotationMirror);
|
||||||
if (migratedType.asType().isPrimitive() || !(migratedType instanceof ClassSymbol)) {
|
if (migratedType.asType().isPrimitive()
|
||||||
|
|| !(migratedType instanceof ClassSymbol migratedClass)) {
|
||||||
return buildDescription(migrationAnnotation)
|
return buildDescription(migrationAnnotation)
|
||||||
.setMessage(String.format("Migration of type '%s' is unsupported", migratedType))
|
.setMessage(String.format("Migration of type '%s' is unsupported", migratedType))
|
||||||
.build();
|
.build();
|
||||||
@@ -111,7 +111,7 @@ public final class ExhaustiveRefasterTypeMigration extends BugChecker implements
|
|||||||
ImmutableList<String> methodsClaimedUnmigrated = getMethodsClaimedUnmigrated(annotationMirror);
|
ImmutableList<String> methodsClaimedUnmigrated = getMethodsClaimedUnmigrated(annotationMirror);
|
||||||
ImmutableList<String> unmigratedMethods =
|
ImmutableList<String> unmigratedMethods =
|
||||||
getMethodsDefinitelyUnmigrated(
|
getMethodsDefinitelyUnmigrated(
|
||||||
tree, (ClassSymbol) migratedType, signatureOrder(methodsClaimedUnmigrated), state);
|
tree, migratedClass, signatureOrder(methodsClaimedUnmigrated), state);
|
||||||
|
|
||||||
if (unmigratedMethods.equals(methodsClaimedUnmigrated)) {
|
if (unmigratedMethods.equals(methodsClaimedUnmigrated)) {
|
||||||
return Description.NO_MATCH;
|
return Description.NO_MATCH;
|
||||||
@@ -160,17 +160,11 @@ public final class ExhaustiveRefasterTypeMigration extends BugChecker implements
|
|||||||
.getValue().stream().map(a -> a.getValue().toString()).collect(toImmutableList());
|
.getValue().stream().map(a -> a.getValue().toString()).collect(toImmutableList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Once only JDK 14 and above are supported, change the
|
|
||||||
// `m.getModifiers().contains(Modifier.PUBLIC)` check to just `m.isPublic()`.
|
|
||||||
private static ImmutableList<String> getMethodsDefinitelyUnmigrated(
|
private static ImmutableList<String> getMethodsDefinitelyUnmigrated(
|
||||||
ClassTree tree, ClassSymbol migratedType, Comparator<String> comparator, VisitorState state) {
|
ClassTree tree, ClassSymbol migratedType, Comparator<String> comparator, VisitorState state) {
|
||||||
Set<MethodSymbol> publicMethods =
|
Set<MethodSymbol> publicMethods =
|
||||||
Streams.stream(
|
Streams.stream(
|
||||||
ASTHelpers.scope(migratedType.members())
|
migratedType.members().getSymbols(m -> m.isPublic() && m instanceof MethodSymbol))
|
||||||
.getSymbols(
|
|
||||||
m ->
|
|
||||||
m.getModifiers().contains(Modifier.PUBLIC)
|
|
||||||
&& m instanceof MethodSymbol))
|
|
||||||
.map(MethodSymbol.class::cast)
|
.map(MethodSymbol.class::cast)
|
||||||
.collect(toCollection(HashSet::new));
|
.collect(toCollection(HashSet::new));
|
||||||
|
|
||||||
|
|||||||
@@ -303,14 +303,7 @@ final class SourceCodeTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Description matchLiteral(LiteralTree tree, VisitorState state) {
|
public Description matchLiteral(LiteralTree tree, VisitorState state) {
|
||||||
// XXX: The character conversion is a workaround for the fact that `ASTHelpers#constValue`
|
|
||||||
// returns an `Integer` value for `char` constants.
|
|
||||||
return Optional.ofNullable(ASTHelpers.constValue(tree))
|
return Optional.ofNullable(ASTHelpers.constValue(tree))
|
||||||
.map(
|
|
||||||
constant ->
|
|
||||||
ASTHelpers.isSubtype(ASTHelpers.getType(tree), state.getSymtab().charType, state)
|
|
||||||
? (char) (int) constant
|
|
||||||
: constant)
|
|
||||||
.map(constant -> describeMatch(tree, addComment(tree, constant, state)))
|
.map(constant -> describeMatch(tree, addComment(tree, constant, state)))
|
||||||
.orElse(Description.NO_MATCH);
|
.orElse(Description.NO_MATCH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,15 +89,63 @@
|
|||||||
}
|
}
|
||||||
return new CollectdReporter(
|
return new CollectdReporter(
|
||||||
registry,
|
registry,
|
||||||
@@ -302,7 +297,7 @@ public class CollectdReporter extends ScheduledReporter {
|
@@ -177,7 +172,7 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static final Logger LOG = LoggerFactory.getLogger(CollectdReporter.class);
|
||||||
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(CollectdReporter.class);
|
||||||
|
private static final String REPORTER_NAME = "collectd-reporter";
|
||||||
|
private static final String FALLBACK_HOST_NAME = "localhost";
|
||||||
|
private static final String COLLECTD_TYPE_GAUGE = "gauge";
|
||||||
|
@@ -224,7 +219,7 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
|
try {
|
||||||
|
return InetAddress.getLocalHost().getHostName();
|
||||||
|
} catch (Exception e) {
|
||||||
|
- LOG.error("Failed to lookup local host name: {}", e.getMessage(), e);
|
||||||
|
+ LOGGER.error("Failed to lookup local host name: {}", e.getMessage(), e);
|
||||||
|
return FALLBACK_HOST_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -263,7 +258,7 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
|
serializeTimer(metaData.plugin(entry.getKey().getKey()), entry.getValue());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
- LOG.warn("Unable to report to Collectd", e);
|
||||||
|
+ LOGGER.warn("Unable to report to Collectd", e);
|
||||||
|
} finally {
|
||||||
|
disconnect(sender);
|
||||||
|
}
|
||||||
|
@@ -279,7 +274,7 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
|
try {
|
||||||
|
sender.disconnect();
|
||||||
|
} catch (Exception e) {
|
||||||
|
- LOG.warn("Error disconnecting from Collectd", e);
|
||||||
|
+ LOGGER.warn("Error disconnecting from Collectd", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -302,9 +297,9 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
try {
|
try {
|
||||||
writer.write(metaData, value);
|
writer.write(metaData, value);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
- LOG.warn("Failed to process metric '" + metaData.getPlugin() + "': " + e.getMessage());
|
- LOG.warn("Failed to process metric '" + metaData.getPlugin() + "': " + e.getMessage());
|
||||||
+ LOG.warn("Failed to process metric '{}': {}", metaData.getPlugin(), e.getMessage());
|
+ LOGGER.warn("Failed to process metric '{}': {}", metaData.getPlugin(), e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Failed to send metric to collectd", e);
|
- LOG.error("Failed to send metric to collectd", e);
|
||||||
|
+ LOGGER.error("Failed to send metric to collectd", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -314,7 +309,7 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
|
} else if (metric.getValue() instanceof Boolean) {
|
||||||
|
write(metaData.typeInstance("value").get(), ((Boolean) metric.getValue()) ? 1 : 0);
|
||||||
|
} else {
|
||||||
|
- LOG.warn(
|
||||||
|
+ LOGGER.warn(
|
||||||
|
"Failed to process metric '{}'. Unsupported gauge of type: {} ",
|
||||||
|
metaData.get().getPlugin(),
|
||||||
|
metric.getValue().getClass().getName());
|
||||||
@@ -336,9 +331,9 @@ public class CollectdReporter extends ScheduledReporter {
|
@@ -336,9 +331,9 @@ public class CollectdReporter extends ScheduledReporter {
|
||||||
private void serializeHistogram(MetaData.Builder metaData, Histogram metric) {
|
private void serializeHistogram(MetaData.Builder metaData, Histogram metric) {
|
||||||
final Snapshot snapshot = metric.getSnapshot();
|
final Snapshot snapshot = metric.getSnapshot();
|
||||||
@@ -476,26 +524,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/CsvReporter.java
|
|
||||||
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/CsvReporter.java
|
|
||||||
@@ -179,7 +179,7 @@ public class CsvReporter extends ScheduledReporter {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(CsvReporter.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(CsvReporter.class);
|
|
||||||
|
|
||||||
private final File directory;
|
|
||||||
private final Locale locale;
|
|
||||||
@@ -391,7 +391,7 @@ public class CsvReporter extends ScheduledReporter {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.warn("Error writing to {}", name, e);
|
|
||||||
+ LOG.warn("Error writing to {}", name, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/ExponentialMovingAverages.java
|
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/ExponentialMovingAverages.java
|
||||||
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/ExponentialMovingAverages.java
|
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/ExponentialMovingAverages.java
|
||||||
@@ -17,9 +17,9 @@ public class ExponentialMovingAverages implements MovingAverages {
|
@@ -17,9 +17,9 @@ public class ExponentialMovingAverages implements MovingAverages {
|
||||||
@@ -990,6 +1018,15 @@
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
@@ -24,7 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
*/
|
||||||
|
public abstract class ScheduledReporter implements Closeable, Reporter {
|
||||||
|
|
||||||
|
- private static final Logger LOG = LoggerFactory.getLogger(ScheduledReporter.class);
|
||||||
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledReporter.class);
|
||||||
|
|
||||||
|
/** A simple named thread factory. */
|
||||||
|
@SuppressWarnings("NullableProblems")
|
||||||
@@ -128,7 +131,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter {
|
@@ -128,7 +131,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter {
|
||||||
durationUnit,
|
durationUnit,
|
||||||
executor,
|
executor,
|
||||||
@@ -1040,6 +1077,33 @@
|
|||||||
protected ScheduledFuture<?> getScheduledFuture(
|
protected ScheduledFuture<?> getScheduledFuture(
|
||||||
long initialDelay, long period, TimeUnit unit, Runnable runnable) {
|
long initialDelay, long period, TimeUnit unit, Runnable runnable) {
|
||||||
return getScheduledFuture(initialDelay, period, unit, runnable, this.executor);
|
return getScheduledFuture(initialDelay, period, unit, runnable, this.executor);
|
||||||
|
@@ -225,7 +224,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter {
|
||||||
|
try {
|
||||||
|
report();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- LOG.error(
|
||||||
|
+ LOGGER.error(
|
||||||
|
"Exception thrown from {}#report. Exception was suppressed.",
|
||||||
|
ScheduledReporter.this.getClass().getSimpleName(),
|
||||||
|
ex);
|
||||||
|
@@ -250,7 +249,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter {
|
||||||
|
try {
|
||||||
|
report();
|
||||||
|
} catch (Exception e) {
|
||||||
|
- LOG.warn("Final reporting of metrics failed.", e);
|
||||||
|
+ LOGGER.warn("Final reporting of metrics failed.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -261,7 +260,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter {
|
||||||
|
executor.shutdownNow(); // Cancel currently executing tasks
|
||||||
|
// Wait a while for tasks to respond to being cancelled
|
||||||
|
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
|
||||||
|
- LOG.warn("ScheduledExecutorService did not terminate.");
|
||||||
|
+ LOGGER.warn("ScheduledExecutorService did not terminate.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/SharedMetricRegistries.java
|
--- a/metrics-core/src/main/java/io/dropwizard/metrics5/SharedMetricRegistries.java
|
||||||
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/SharedMetricRegistries.java
|
+++ b/metrics-core/src/main/java/io/dropwizard/metrics5/SharedMetricRegistries.java
|
||||||
@@ -1,5 +1,7 @@
|
@@ -1,5 +1,7 @@
|
||||||
@@ -1200,32 +1264,15 @@
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,8 +14,8 @@ import org.junit.jupiter.api.Test;
|
@@ -15,7 +14,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
-class CachedGaugeTest {
|
-class CachedGaugeTest {
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(CachedGaugeTest.class);
|
|
||||||
+final class CachedGaugeTest {
|
+final class CachedGaugeTest {
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(CachedGaugeTest.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CachedGaugeTest.class);
|
||||||
private static final int THREAD_COUNT = 10;
|
private static final int THREAD_COUNT = 10;
|
||||||
private static final long RUNNING_TIME_MILLIS = TimeUnit.SECONDS.toMillis(10);
|
private static final long RUNNING_TIME_MILLIS = TimeUnit.SECONDS.toMillis(10);
|
||||||
|
|
||||||
@@ -100,12 +99,12 @@ class CachedGaugeTest {
|
|
||||||
Integer newValue = shortTimeoutGauge.getValue();
|
|
||||||
|
|
||||||
if (newValue == null) {
|
|
||||||
- LOGGER.warn("Cached gauge returned null value");
|
|
||||||
+ LOG.warn("Cached gauge returned null value");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newValue < lastValue) {
|
|
||||||
- LOGGER.error(
|
|
||||||
+ LOG.error(
|
|
||||||
"Cached gauge returned stale value, last: {}, new: {}",
|
|
||||||
lastValue,
|
|
||||||
newValue);
|
|
||||||
@@ -122,7 +121,7 @@ class CachedGaugeTest {
|
@@ -122,7 +121,7 @@ class CachedGaugeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1899,29 +1946,16 @@
|
|||||||
assertThat(histogram.getSnapshot()).isEqualTo(snapshot);
|
assertThat(histogram.getSnapshot()).isEqualTo(snapshot);
|
||||||
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedExecutorServiceTest.java
|
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedExecutorServiceTest.java
|
||||||
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedExecutorServiceTest.java
|
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedExecutorServiceTest.java
|
||||||
@@ -19,10 +19,9 @@ import org.junit.jupiter.api.Test;
|
@@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
-class InstrumentedExecutorServiceTest {
|
-class InstrumentedExecutorServiceTest {
|
||||||
+final class InstrumentedExecutorServiceTest {
|
+final class InstrumentedExecutorServiceTest {
|
||||||
|
|
||||||
- private static final Logger LOGGER =
|
private static final Logger LOGGER =
|
||||||
- LoggerFactory.getLogger(InstrumentedExecutorServiceTest.class);
|
LoggerFactory.getLogger(InstrumentedExecutorServiceTest.class);
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(InstrumentedExecutorServiceTest.class);
|
@@ -115,8 +115,8 @@ class InstrumentedExecutorServiceTest {
|
||||||
private ExecutorService executor;
|
|
||||||
private MetricRegistry registry;
|
|
||||||
private InstrumentedExecutorService instrumentedExecutorService;
|
|
||||||
@@ -48,7 +47,7 @@ class InstrumentedExecutorServiceTest {
|
|
||||||
void tearDown() throws Exception {
|
|
||||||
instrumentedExecutorService.shutdown();
|
|
||||||
if (!instrumentedExecutorService.awaitTermination(2, TimeUnit.SECONDS)) {
|
|
||||||
- LOGGER.error("InstrumentedExecutorService did not terminate.");
|
|
||||||
+ LOG.error("InstrumentedExecutorService did not terminate.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -115,8 +114,8 @@ class InstrumentedExecutorServiceTest {
|
|
||||||
assertThat(idle.getSnapshot().size()).isEqualTo(1);
|
assertThat(idle.getSnapshot().size()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1931,7 +1965,7 @@
|
|||||||
void reportsTasksInformationForThreadPoolExecutor() throws Exception {
|
void reportsTasksInformationForThreadPoolExecutor() throws Exception {
|
||||||
executor =
|
executor =
|
||||||
new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32));
|
new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32));
|
||||||
@@ -180,7 +179,7 @@ class InstrumentedExecutorServiceTest {
|
@@ -180,7 +180,7 @@ class InstrumentedExecutorServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1940,7 +1974,7 @@
|
|||||||
executor =
|
executor =
|
||||||
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1));
|
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1));
|
||||||
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "tp");
|
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "tp");
|
||||||
@@ -207,7 +206,7 @@ class InstrumentedExecutorServiceTest {
|
@@ -207,7 +207,7 @@ class InstrumentedExecutorServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1949,7 +1983,7 @@
|
|||||||
executor =
|
executor =
|
||||||
new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32));
|
new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32));
|
||||||
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "stp");
|
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "stp");
|
||||||
@@ -236,8 +235,8 @@ class InstrumentedExecutorServiceTest {
|
@@ -236,8 +236,8 @@ class InstrumentedExecutorServiceTest {
|
||||||
MetricRegistry.name("stp", "tasks.capacity"));
|
MetricRegistry.name("stp", "tasks.capacity"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1959,7 +1993,7 @@
|
|||||||
void reportsTasksInformationForForkJoinPool() throws Exception {
|
void reportsTasksInformationForForkJoinPool() throws Exception {
|
||||||
executor = Executors.newWorkStealingPool(4);
|
executor = Executors.newWorkStealingPool(4);
|
||||||
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "fjp");
|
instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "fjp");
|
||||||
@@ -291,7 +290,7 @@ class InstrumentedExecutorServiceTest {
|
@@ -291,7 +291,7 @@ class InstrumentedExecutorServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1970,17 +2004,15 @@
|
|||||||
|
|
||||||
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedScheduledExecutorServiceTest.java
|
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedScheduledExecutorServiceTest.java
|
||||||
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedScheduledExecutorServiceTest.java
|
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedScheduledExecutorServiceTest.java
|
||||||
@@ -13,8 +13,8 @@ import org.junit.jupiter.api.Test;
|
@@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
-class InstrumentedScheduledExecutorServiceTest {
|
-class InstrumentedScheduledExecutorServiceTest {
|
||||||
- private static final Logger LOGGER =
|
|
||||||
+final class InstrumentedScheduledExecutorServiceTest {
|
+final class InstrumentedScheduledExecutorServiceTest {
|
||||||
+ private static final Logger LOG =
|
private static final Logger LOGGER =
|
||||||
LoggerFactory.getLogger(InstrumentedScheduledExecutorServiceTest.class);
|
LoggerFactory.getLogger(InstrumentedScheduledExecutorServiceTest.class);
|
||||||
|
|
||||||
private final ScheduledExecutorService scheduledExecutor =
|
|
||||||
@@ -35,17 +35,17 @@ class InstrumentedScheduledExecutorServiceTest {
|
@@ -35,17 +35,17 @@ class InstrumentedScheduledExecutorServiceTest {
|
||||||
private final Histogram percentOfPeriod = registry.histogram("xs.scheduled.percent-of-period");
|
private final Histogram percentOfPeriod = registry.histogram("xs.scheduled.percent-of-period");
|
||||||
|
|
||||||
@@ -2338,15 +2370,6 @@
|
|||||||
assertThat(completed.getCount()).isNotEqualTo(0);
|
assertThat(completed.getCount()).isNotEqualTo(0);
|
||||||
assertThat(duration.getCount()).isNotEqualTo(0);
|
assertThat(duration.getCount()).isNotEqualTo(0);
|
||||||
assertThat(duration.getSnapshot().size()).isNotEqualTo(0);
|
assertThat(duration.getSnapshot().size()).isNotEqualTo(0);
|
||||||
@@ -322,7 +322,7 @@ class InstrumentedScheduledExecutorServiceTest {
|
|
||||||
void tearDown() throws Exception {
|
|
||||||
instrumentedScheduledExecutor.shutdown();
|
|
||||||
if (!instrumentedScheduledExecutor.awaitTermination(2, TimeUnit.SECONDS)) {
|
|
||||||
- LOGGER.error("InstrumentedScheduledExecutorService did not terminate.");
|
|
||||||
+ LOG.error("InstrumentedScheduledExecutorService did not terminate.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedThreadFactoryTest.java
|
--- a/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedThreadFactoryTest.java
|
||||||
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedThreadFactoryTest.java
|
+++ b/metrics-core/src/test/java/io/dropwizard/metrics5/InstrumentedThreadFactoryTest.java
|
||||||
@@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
|
@@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
@@ -3801,15 +3824,6 @@
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
@@ -29,7 +32,7 @@ public class Graphite implements GraphiteSender {
|
|
||||||
private Writer writer;
|
|
||||||
private int failures;
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(Graphite.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(Graphite.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new client which connects to the given address using the default {@link
|
|
||||||
@@ -63,13 +66,9 @@ public class Graphite implements GraphiteSender {
|
@@ -63,13 +66,9 @@ public class Graphite implements GraphiteSender {
|
||||||
* @param charset the character set used by the server
|
* @param charset the character set used by the server
|
||||||
*/
|
*/
|
||||||
@@ -3837,24 +3851,6 @@
|
|||||||
InetSocketAddress address = this.address;
|
InetSocketAddress address = this.address;
|
||||||
// the previous dns retry logic did not work, as address.getAddress would always return the
|
// the previous dns retry logic did not work, as address.getAddress would always return the
|
||||||
// cached value
|
// cached value
|
||||||
@@ -178,7 +175,7 @@ public class Graphite implements GraphiteSender {
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
- LOGGER.debug("Error closing writer", ex);
|
|
||||||
+ LOG.debug("Error closing writer", ex);
|
|
||||||
} finally {
|
|
||||||
this.writer = null;
|
|
||||||
}
|
|
||||||
@@ -188,7 +185,7 @@ public class Graphite implements GraphiteSender {
|
|
||||||
socket.close();
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
- LOGGER.debug("Error closing socket", ex);
|
|
||||||
+ LOG.debug("Error closing socket", ex);
|
|
||||||
} finally {
|
|
||||||
this.socket = null;
|
|
||||||
}
|
|
||||||
--- a/metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQ.java
|
--- a/metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQ.java
|
||||||
+++ b/metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQ.java
|
+++ b/metrics-graphite/src/main/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQ.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,5 +1,6 @@
|
||||||
@@ -3923,39 +3919,7 @@
|
|||||||
this.addMetricAttributesAsTags = false;
|
this.addMetricAttributesAsTags = false;
|
||||||
this.floatingPointFormatter = DEFAULT_FP_FORMATTER;
|
this.floatingPointFormatter = DEFAULT_FP_FORMATTER;
|
||||||
}
|
}
|
||||||
@@ -249,7 +247,7 @@ public class GraphiteReporter extends ScheduledReporter {
|
@@ -455,9 +453,9 @@ public class GraphiteReporter extends ScheduledReporter {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(GraphiteReporter.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(GraphiteReporter.class);
|
|
||||||
// the Carbon plaintext format is pretty underspecified, but it seems like it just wants
|
|
||||||
// US-formatted digits
|
|
||||||
private static final DoubleFunction<String> DEFAULT_FP_FORMATTER =
|
|
||||||
@@ -430,12 +428,12 @@ public class GraphiteReporter extends ScheduledReporter {
|
|
||||||
}
|
|
||||||
graphite.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.warn("Unable to report to Graphite", graphite, e);
|
|
||||||
+ LOG.warn("Unable to report to Graphite", graphite, e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
graphite.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
- LOGGER.warn("Error closing Graphite", graphite, e1);
|
|
||||||
+ LOG.warn("Error closing Graphite", graphite, e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -448,16 +446,16 @@ public class GraphiteReporter extends ScheduledReporter {
|
|
||||||
try {
|
|
||||||
graphite.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.debug("Error disconnecting from Graphite", graphite, e);
|
|
||||||
+ LOG.debug("Error disconnecting from Graphite", graphite, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reportTimer(MetricName name, Timer timer, long timestamp) throws IOException {
|
private void reportTimer(MetricName name, Timer timer, long timestamp) throws IOException {
|
||||||
final Snapshot snapshot = timer.getSnapshot();
|
final Snapshot snapshot = timer.getSnapshot();
|
||||||
@@ -4017,15 +3981,6 @@
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@@ -48,7 +49,7 @@ public class PickledGraphite implements GraphiteSender {
|
|
||||||
QUOTE = '\'',
|
|
||||||
LF = '\n';
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(PickledGraphite.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(PickledGraphite.class);
|
|
||||||
private static final int DEFAULT_BATCH_SIZE = 100;
|
|
||||||
|
|
||||||
private int batchSize;
|
|
||||||
@@ -173,9 +174,7 @@ public class PickledGraphite implements GraphiteSender {
|
@@ -173,9 +174,7 @@ public class PickledGraphite implements GraphiteSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4046,17 +4001,6 @@
|
|||||||
try {
|
try {
|
||||||
byte[] payload = pickleMetrics(metrics);
|
byte[] payload = pickleMetrics(metrics);
|
||||||
byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array();
|
byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array();
|
||||||
@@ -260,8 +259,8 @@ public class PickledGraphite implements GraphiteSender {
|
|
||||||
outputStream.write(payload);
|
|
||||||
outputStream.flush();
|
|
||||||
|
|
||||||
- if (LOGGER.isDebugEnabled()) {
|
|
||||||
- LOGGER.debug("Wrote {} metrics", metrics.size());
|
|
||||||
+ if (LOG.isDebugEnabled()) {
|
|
||||||
+ LOG.debug("Wrote {} metrics", metrics.size());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
this.failures++;
|
|
||||||
--- a/metrics-graphite/src/test/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQTest.java
|
--- a/metrics-graphite/src/test/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQTest.java
|
||||||
+++ b/metrics-graphite/src/test/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQTest.java
|
+++ b/metrics-graphite/src/test/java/io/dropwizard/metrics5/graphite/GraphiteRabbitMQTest.java
|
||||||
@@ -8,7 +8,6 @@ import static org.mockito.Mockito.anyString;
|
@@ -8,7 +8,6 @@ import static org.mockito.Mockito.anyString;
|
||||||
@@ -4475,15 +4419,6 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,7 +29,7 @@ import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/** A registry for health checks. */
|
|
||||||
public class HealthCheckRegistry {
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(HealthCheckRegistry.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(HealthCheckRegistry.class);
|
|
||||||
private static final int ASYNC_EXECUTOR_POOL_SIZE = 2;
|
|
||||||
|
|
||||||
private final ConcurrentMap<String, HealthCheck> healthChecks;
|
|
||||||
@@ -92,9 +94,8 @@ public class HealthCheckRegistry {
|
@@ -92,9 +94,8 @@ public class HealthCheckRegistry {
|
||||||
public void register(String name, HealthCheck healthCheck) {
|
public void register(String name, HealthCheck healthCheck) {
|
||||||
HealthCheck registered;
|
HealthCheck registered;
|
||||||
@@ -4514,13 +4449,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,12 +218,12 @@ public class HealthCheckRegistry {
|
@@ -222,7 +223,7 @@ public class HealthCheckRegistry {
|
||||||
try {
|
|
||||||
results.put(entry.getKey(), entry.getValue().get());
|
|
||||||
} catch (Exception e) {
|
|
||||||
- LOGGER.warn("Error executing health check {}", entry.getKey(), e);
|
|
||||||
+ LOG.warn("Error executing health check {}", entry.getKey(), e);
|
|
||||||
results.put(entry.getKey(), HealthCheck.Result.unhealthy(e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5357,39 +5286,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,7 +196,7 @@ public class InfluxDbReporter extends GarbageFreeScheduledReporter {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(InfluxDbReporter.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(InfluxDbReporter.class);
|
|
||||||
private static final String VALUE = "value";
|
|
||||||
|
|
||||||
private final Clock clock;
|
|
||||||
@@ -279,12 +279,12 @@ public class InfluxDbReporter extends GarbageFreeScheduledReporter {
|
|
||||||
}
|
|
||||||
sender.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.warn("Unable to report to InfluxDb", sender, e);
|
|
||||||
+ LOG.warn("Unable to report to InfluxDb", sender, e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
sender.disconnect();
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.warn("Error disconnecting InfluxDb", sender, e);
|
|
||||||
+ LOG.warn("Error disconnecting InfluxDb", sender, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -297,7 +297,7 @@ public class InfluxDbReporter extends GarbageFreeScheduledReporter {
|
|
||||||
try {
|
|
||||||
sender.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
- LOGGER.debug("Error disconnecting from InfluxDb", e);
|
|
||||||
+ LOG.debug("Error disconnecting from InfluxDb", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--- a/metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbUdpSender.java
|
--- a/metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbUdpSender.java
|
||||||
+++ b/metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbUdpSender.java
|
+++ b/metrics-influxdb/src/main/java/io/dropwizard/metrics5/influxdb/InfluxDbUdpSender.java
|
||||||
@@ -1,5 +1,7 @@
|
@@ -1,5 +1,7 @@
|
||||||
@@ -6065,15 +5961,6 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -33,7 +33,7 @@ public class JCacheGaugeSet implements MetricSet {
|
|
||||||
private static final String M_BEAN_COORDINATES =
|
|
||||||
"javax.cache:type=CacheStatistics,CacheManager=*,Cache=*";
|
|
||||||
|
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(JCacheGaugeSet.class);
|
|
||||||
+ private static final Logger LOG = LoggerFactory.getLogger(JCacheGaugeSet.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<MetricName, Metric> getMetrics() {
|
|
||||||
@@ -52,7 +52,7 @@ public class JCacheGaugeSet implements MetricSet {
|
@@ -52,7 +52,7 @@ public class JCacheGaugeSet implements MetricSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6083,15 +5970,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<ObjectInstance> getCacheBeans() {
|
private Set<ObjectInstance> 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
|
--- a/metrics-jcache/src/test/java/JCacheGaugeSetTest.java
|
||||||
+++ b/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;
|
@@ -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 char[] QUOTABLE_CHARS = new char[] {',', '=', ':', '"'};
|
||||||
- private static final Logger LOGGER = LoggerFactory.getLogger(JmxReporter.class);
|
- 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
|
@Override
|
||||||
public ObjectName createName(String type, String domain, MetricName name) {
|
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"))) {
|
|| shouldQuote(objectName.getKeyProperty("type"))) {
|
||||||
properties.put("type", ObjectName.quote(type));
|
properties.put("type", ObjectName.quote(type));
|
||||||
}
|
}
|
||||||
@@ -8476,12 +8354,6 @@
|
|||||||
} catch (MalformedObjectNameException e) {
|
} catch (MalformedObjectNameException e) {
|
||||||
try {
|
try {
|
||||||
return new ObjectName(domain, "name", ObjectName.quote(name.getKey()));
|
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
|
--- a/metrics-jmx/src/main/java/io/dropwizard/metrics5/jmx/JmxReporter.java
|
||||||
+++ b/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 @@
|
@@ -1,5 +1,9 @@
|
||||||
@@ -8542,147 +8414,6 @@
|
|||||||
return this;
|
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
|
--- a/metrics-jmx/src/test/java/io/dropwizard/metrics5/jmx/DefaultObjectNameFactoryTest.java
|
||||||
+++ b/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;
|
@@ -7,7 +7,7 @@ import io.dropwizard.metrics5.MetricName;
|
||||||
@@ -9002,21 +8733,7 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.management.JMException;
|
import javax.management.JMException;
|
||||||
@@ -19,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
@@ -47,6 +48,6 @@ public class BufferPoolMetricSet implements MetricSet {
|
||||||
* <p>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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/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:[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-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:[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,16] [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,17] [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:[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-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
|
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/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:[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-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:[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,16] [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-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:[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
|
metrics-jdbi3/src/test/java/io/dropwizard/metrics5/jdbi3/strategies/SmartNameStrategyTest.java:[24,20] [deprecation] InstrumentedTimingCollector in io.dropwizard.metrics5.jdbi3 has been deprecated
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ repository='https://github.com/dropwizard/metrics.git'
|
|||||||
revision='v5.0.0-rc22'
|
revision='v5.0.0-rc22'
|
||||||
additional_build_flags=''
|
additional_build_flags=''
|
||||||
additional_source_directories=''
|
additional_source_directories=''
|
||||||
# XXX: Minimize the diff by including
|
shared_error_prone_flags='-XepExcludedPaths:.*/target/generated-sources/.* -XepOpt:Slf4jLoggerDeclaration:CanonicalStaticLoggerName=LOGGER'
|
||||||
# `-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/.*'
|
|
||||||
patch_error_prone_flags=''
|
patch_error_prone_flags=''
|
||||||
validation_error_prone_flags=''
|
validation_error_prone_flags=''
|
||||||
validation_build_flags=''
|
validation_build_flags=''
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@@ -205,8 +205,8 @@
|
|||||||
<version.auto-service>1.1.1</version.auto-service>
|
<version.auto-service>1.1.1</version.auto-service>
|
||||||
<version.auto-value>1.11.0</version.auto-value>
|
<version.auto-value>1.11.0</version.auto-value>
|
||||||
<version.error-prone>${version.error-prone-orig}</version.error-prone>
|
<version.error-prone>${version.error-prone-orig}</version.error-prone>
|
||||||
<version.error-prone-fork>${version.error-prone-orig}-picnic-4</version.error-prone-fork>
|
<version.error-prone-fork>${version.error-prone-orig}-picnic-1</version.error-prone-fork>
|
||||||
<version.error-prone-orig>2.36.0</version.error-prone-orig>
|
<version.error-prone-orig>2.37.0</version.error-prone-orig>
|
||||||
<version.error-prone-slf4j>0.1.28</version.error-prone-slf4j>
|
<version.error-prone-slf4j>0.1.28</version.error-prone-slf4j>
|
||||||
<version.guava-beta-checker>1.0</version.guava-beta-checker>
|
<version.guava-beta-checker>1.0</version.guava-beta-checker>
|
||||||
<version.jdk>17</version.jdk>
|
<version.jdk>17</version.jdk>
|
||||||
@@ -1939,9 +1939,7 @@
|
|||||||
-XepOpt:NullAway:AssertsEnabled=true
|
-XepOpt:NullAway:AssertsEnabled=true
|
||||||
-XepOpt:NullAway:CheckOptionalEmptiness=true
|
-XepOpt:NullAway:CheckOptionalEmptiness=true
|
||||||
-XepOpt:Nullness:Conservative=false
|
-XepOpt:Nullness:Conservative=false
|
||||||
-XepOpt:StatementSwitchToExpressionSwitch:EnableAssignmentSwitchConversion=true
|
|
||||||
-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true
|
-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true
|
||||||
-XepOpt:StatementSwitchToExpressionSwitch:EnableReturnSwitchConversion=true
|
|
||||||
<!-- Append additional custom arguments. -->
|
<!-- Append additional custom arguments. -->
|
||||||
${error-prone.patch-args}
|
${error-prone.patch-args}
|
||||||
${error-prone.self-check-args}
|
${error-prone.self-check-args}
|
||||||
|
|||||||
@@ -118,11 +118,12 @@ public final class IsEmpty implements Matcher<ExpressionTree> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEmptyCollectionConstructor(ExpressionTree tree, VisitorState state) {
|
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;
|
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))) {
|
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
|
* This is a default constructor, or a constructor that creates an empty collection using
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
|||||||
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
||||||
import static com.google.errorprone.BugPattern.LinkType.NONE;
|
import static com.google.errorprone.BugPattern.LinkType.NONE;
|
||||||
import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
|
import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Comparator.naturalOrder;
|
import static java.util.Comparator.naturalOrder;
|
||||||
import static tech.picnic.errorprone.refaster.runner.Refaster.INCLUDED_RULES_PATTERN_FLAG;
|
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.Iterables;
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.common.io.Resources;
|
||||||
import com.google.errorprone.BugCheckerRefactoringTestHelper;
|
import com.google.errorprone.BugCheckerRefactoringTestHelper;
|
||||||
import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode;
|
import com.google.errorprone.BugCheckerRefactoringTestHelper.TestMode;
|
||||||
import com.google.errorprone.BugPattern;
|
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.EndPosTable;
|
||||||
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
||||||
import com.sun.tools.javac.util.Position;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -124,13 +129,15 @@ public final class RefasterRuleCollection extends BugChecker implements Compilat
|
|||||||
*/
|
*/
|
||||||
public static void validate(Class<?> clazz) {
|
public static void validate(Class<?> clazz) {
|
||||||
String className = clazz.getSimpleName();
|
String className = clazz.getSimpleName();
|
||||||
|
String inputResource = className + "TestInput.java";
|
||||||
|
String outputResource = className + "TestOutput.java";
|
||||||
|
|
||||||
BugCheckerRefactoringTestHelper.newInstance(RefasterRuleCollection.class, clazz)
|
BugCheckerRefactoringTestHelper.newInstance(RefasterRuleCollection.class, clazz)
|
||||||
.setArgs(
|
.setArgs(
|
||||||
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||||
"-XepOpt:" + RULE_COLLECTION_FLAG + '=' + className)
|
"-XepOpt:" + RULE_COLLECTION_FLAG + '=' + className)
|
||||||
.addInput(className + "TestInput.java")
|
.addInputLines(inputResource, loadResource(clazz, inputResource))
|
||||||
.addOutput(className + "TestOutput.java")
|
.addOutputLines(outputResource, loadResource(clazz, outputResource))
|
||||||
.doTest(TestMode.TEXT_MATCH);
|
.doTest(TestMode.TEXT_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +254,15 @@ public final class RefasterRuleCollection extends BugChecker implements Compilat
|
|||||||
return value.substring(index + 1);
|
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 class UnexpectedMatchReporter extends TreeScanner<@Nullable Void, VisitorState> {
|
||||||
private final ImmutableRangeMap<Integer, String> indexedMatches;
|
private final ImmutableRangeMap<Integer, String> indexedMatches;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user