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;
From 40b3c87b72d82c99dbee185da1cb7e7a723c6690 Mon Sep 17 00:00:00 2001
From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com>
Date: Sat, 22 Mar 2025 12:54:04 +0100
Subject: [PATCH 52/70] Upgrade Spring 6.2.4 -> 6.2.5 (#1602)
See:
- https://github.com/spring-projects/spring-framework/releases/tag/v6.2.5
- https://github.com/spring-projects/spring-framework/compare/v6.2.4...v6.2.5
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index abf8077f..378a082b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -510,7 +510,7 @@
org.springframework
spring-framework-bom
- 6.2.4
+ 6.2.5
pom
import
From c3351b9ee160a5316f7c0706c0f6fc9fd9671dfd Mon Sep 17 00:00:00 2001
From: Tim te Beek
Date: Sun, 23 Mar 2025 11:13:24 +0100
Subject: [PATCH 53/70] Introduce two `FileRules` Refaster rules (#1596)
Invoking `File#mkdirs` before testing for existence of the specified
path, rather than the other way around, avoids a subtle concurrency
issue.
See also openrewrite/rewrite#5189.
---
.../errorprone/refasterrules/FileRules.java | 33 +++++++++++++++++++
.../refasterrules/FileRulesTestInput.java | 12 +++++++
.../refasterrules/FileRulesTestOutput.java | 12 +++++++
3 files changed, 57 insertions(+)
diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/FileRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/FileRules.java
index 065b63c4..f6fb1695 100644
--- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/FileRules.java
+++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/FileRules.java
@@ -4,6 +4,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.errorprone.refaster.Refaster;
import com.google.errorprone.refaster.annotation.AfterTemplate;
+import com.google.errorprone.refaster.annotation.AlsoNegation;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
import com.google.errorprone.refaster.annotation.Repeated;
import java.io.File;
@@ -11,6 +12,7 @@ import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileAttribute;
@@ -141,4 +143,35 @@ final class FileRules {
return Files.createTempFile(directory.toPath(), prefix, suffix).toFile();
}
}
+
+ /**
+ * Invoke {@link File#mkdirs()} before {@link Files#exists(Path, LinkOption...)} to avoid
+ * concurrency issues.
+ */
+ static final class PathToFileMkDirsFilesExists {
+ @BeforeTemplate
+ boolean before(Path path) {
+ return Files.exists(path) || path.toFile().mkdirs();
+ }
+
+ @AfterTemplate
+ @AlsoNegation
+ boolean after(Path path) {
+ return path.toFile().mkdirs() || Files.exists(path);
+ }
+ }
+
+ /** Invoke {@link File#mkdirs()} before {@link File#exists()} to avoid concurrency issues. */
+ static final class FileMkDirsFileExists {
+ @BeforeTemplate
+ boolean before(File file) {
+ return file.exists() || file.mkdirs();
+ }
+
+ @AfterTemplate
+ @AlsoNegation
+ boolean after(File file) {
+ return file.mkdirs() || file.exists();
+ }
+ }
}
diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestInput.java
index 4863bb1a..5425fb2e 100644
--- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestInput.java
+++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestInput.java
@@ -39,4 +39,16 @@ final class FileRulesTest implements RefasterRuleCollectionTestCase {
File testFilesCreateTempFileInCustomDirectoryToFile() throws IOException {
return File.createTempFile("foo", "bar", new File("baz"));
}
+
+ ImmutableSet testPathToFileMkDirsFilesExists() {
+ return ImmutableSet.of(
+ Files.exists(Path.of("foo")) || Path.of("foo").toFile().mkdirs(),
+ !Files.exists(Path.of("bar")) && !Path.of("bar").toFile().mkdirs());
+ }
+
+ ImmutableSet testFileMkDirsFileExists() {
+ return ImmutableSet.of(
+ new File("foo").exists() || new File("foo").mkdirs(),
+ !new File("bar").exists() && !new File("bar").mkdirs());
+ }
}
diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestOutput.java
index 0e987bcf..2f4ecfab 100644
--- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestOutput.java
+++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/FileRulesTestOutput.java
@@ -39,4 +39,16 @@ final class FileRulesTest implements RefasterRuleCollectionTestCase {
File testFilesCreateTempFileInCustomDirectoryToFile() throws IOException {
return Files.createTempFile(new File("baz").toPath(), "foo", "bar").toFile();
}
+
+ ImmutableSet testPathToFileMkDirsFilesExists() {
+ return ImmutableSet.of(
+ Path.of("foo").toFile().mkdirs() || Files.exists(Path.of("foo")),
+ !Path.of("bar").toFile().mkdirs() && !Files.exists(Path.of("bar")));
+ }
+
+ ImmutableSet testFileMkDirsFileExists() {
+ return ImmutableSet.of(
+ new File("foo").mkdirs() || new File("foo").exists(),
+ !new File("bar").mkdirs() && !new File("bar").exists());
+ }
}
From 7b14711ecf9782fbf6f4a38143c4c99e220339c9 Mon Sep 17 00:00:00 2001
From: Julian Broudy
Date: Sun, 23 Mar 2025 11:26:19 +0100
Subject: [PATCH 54/70] Extend `FluxJust` Refaster rule (#1581)
---
.../picnic/errorprone/refasterrules/ReactorRules.java | 9 ++++++++-
.../errorprone/refasterrules/ReactorRulesTestInput.java | 7 ++++++-
.../errorprone/refasterrules/ReactorRulesTestOutput.java | 2 +-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java
index 7eb3af75..12c4f39d 100644
--- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java
+++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java
@@ -489,9 +489,16 @@ final class ReactorRules {
return Flux.range(value, 1);
}
+ // XXX: Consider generalizing part of this template using an Error Prone check that covers any
+ // sequence of explicitly enumerated values passed to an iteration order-preserving collection
+ // factory method.
@BeforeTemplate
Flux before(T value) {
- return Mono.just(value).repeat().take(1);
+ return Refaster.anyOf(
+ Mono.just(value).flux(),
+ Mono.just(value).repeat().take(1),
+ Flux.fromIterable(ImmutableList.of(value)),
+ Flux.fromIterable(ImmutableSet.of(value)));
}
@AfterTemplate
diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java
index fe4c9dcf..b87e5783 100644
--- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java
+++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java
@@ -188,7 +188,12 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
}
ImmutableSet> testFluxJust() {
- return ImmutableSet.of(Flux.range(0, 1), Mono.just(2).repeat().take(1));
+ return ImmutableSet.of(
+ Flux.range(0, 1),
+ Mono.just(2).flux(),
+ Mono.just(3).repeat().take(1),
+ Flux.fromIterable(ImmutableList.of(4)),
+ Flux.fromIterable(ImmutableSet.of(5)));
}
ImmutableSet> testMonoIdentity() {
diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java
index e48cca28..4aa24950 100644
--- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java
+++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java
@@ -192,7 +192,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase {
}
ImmutableSet> testFluxJust() {
- return ImmutableSet.of(Flux.just(0), Flux.just(2));
+ return ImmutableSet.of(Flux.just(0), Flux.just(2), Flux.just(3), Flux.just(4), Flux.just(5));
}
ImmutableSet> testMonoIdentity() {
From d8cae04a98882ec8bd282acb0df6eb08e0847a4e Mon Sep 17 00:00:00 2001
From: Picnic-DevPla-Bot <168541957+Picnic-DevPla-Bot@users.noreply.github.com>
Date: Sun, 23 Mar 2025 11:59:48 +0100
Subject: [PATCH 55/70] Upgrade Byte Buddy 1.17.2 -> 1.17.3 (#1603)
See:
- https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.17.3
- https://github.com/raphw/byte-buddy/compare/byte-buddy-1.17.2...byte-buddy-1.17.3
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 378a082b..c538088f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -422,7 +422,7 @@
net.bytebuddy
byte-buddy
- 1.17.2
+ 1.17.3
- 2025-02-02T12:19:40Z
+ 2025-03-24T10:36:40Z
UTF-8
- 2025-03-24T10:36:40Z
+ 2025-03-24T10:41:07Z
UTF-8