This is an automated email from the ASF dual-hosted git repository. ifesdjeen pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/cassandra-simulator.git
commit f8db384c672dd8f8064e13a2bfc3883af8aefb8c Author: Alex Petrov <[email protected]> AuthorDate: Thu Jul 23 17:11:07 2026 +0000 UNREVIEWED: Enforce simple Java type names with Semgrep --- .semgrep.yml | 17 +++++++++++ .semgrepignore | 5 ++++ build.gradle | 33 ++++++++++++++++++++++ .../cassandra/utils/concurrent/Semaphore.java | 1 + .../simulator_test/SchedulerIntegrationTest.java | 10 ++++--- .../java/org/apache/cassandra/io/util/File.java | 2 ++ .../org/apache/cassandra/io/util/PathUtils.java | 6 ++-- .../java/org/apache/cassandra/journal/Segment.java | 7 +++-- .../main/java/org/apache/cassandra/utils/Crc.java | 3 +- .../simulator/asm/MonitorMethodTransformer.java | 2 +- .../SimulationContextClassLoaderOwnershipTest.java | 3 +- .../SimulationContextClassRoutingTest.java | 7 +++-- .../SimulationContextIntegrationTest.java | 5 ++-- .../SimulationContextSharedClassTest.java | 5 ++-- .../systems/InterceptingCountDownLatch.java | 3 +- .../systems/InterceptorOfGlobalMethods.java | 28 ++++++++++-------- .../cassandra/simulator/utils/Closeable.java | 1 + .../cassandra/simulator/utils/Throwables.java | 5 ++-- .../SimulatorHostClassLoaderReproTest.java | 3 +- .../cassandra/simulator/io/InstrumentedFile.java | 2 ++ 20 files changed, 114 insertions(+), 34 deletions(-) diff --git a/.semgrep.yml b/.semgrep.yml new file mode 100644 index 0000000..aec01fe --- /dev/null +++ b/.semgrep.yml @@ -0,0 +1,17 @@ +rules: + - id: java.no-fqn + languages: [java] + severity: ERROR + message: Import $FQN and use its simple name instead of a fully qualified type name. + paths: + include: + - "**/src/**/*.java" + pattern-regex: |- + (?mx) + ^[\t ]*(?:package|import)\b[^\r\n]*(*SKIP)(*F) + | //[^\r\n]*(*SKIP)(*F) + | /\*(?s:.*?)\*/(*SKIP)(*F) + | """(?s:.*?)"""(*SKIP)(*F) + | "(?:\\.|[^"\\\r\n])*"(*SKIP)(*F) + | '(?:\\.|[^'\\\r\n])*'(*SKIP)(*F) + | (?P<FQN>\b(?:[a-z_][A-Za-z0-9_$]*\.)+[A-Z][A-Za-z0-9_$]*\b) diff --git a/.semgrepignore b/.semgrepignore new file mode 100644 index 0000000..7e6d989 --- /dev/null +++ b/.semgrepignore @@ -0,0 +1,5 @@ +# Override Semgrep's built-in test-directory exclusion; test sources are checked too. +.git/ +.gradle/ +.idea/ +**/build/ diff --git a/build.gradle b/build.gradle index 1f60733..6ae5d52 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,32 @@ +def semgrepExecutable = providers.gradleProperty('semgrepExecutable') + .orElse(providers.environmentVariable('SEMGREP_EXECUTABLE')) + .orElse('semgrep') +def semgrepConfig = layout.projectDirectory.file('.semgrep.yml') +def semgrepIgnore = layout.projectDirectory.file('.semgrepignore') +def semgrepSources = files(subprojects.collect { subproject -> + subproject.fileTree('src') { + include '**/*.java' + } +}) + +tasks.register('semgrepCheck', Exec) { + group = 'verification' + description = 'Runs the Semgrep source checks.' + + inputs.file semgrepConfig + inputs.file semgrepIgnore + inputs.files semgrepSources + + commandLine semgrepExecutable.get(), + 'scan', + '--config', semgrepConfig.asFile, + '--error', + '--metrics=off', + '--disable-version-check', + '--quiet', + projectDir +} + subprojects { apply plugin: 'java' @@ -17,4 +46,8 @@ subprojects { useJUnitPlatform() jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED' } + + tasks.named('check') { + dependsOn rootProject.tasks.named('semgrepCheck') + } } diff --git a/integration-test/src/main/java/org/apache/cassandra/utils/concurrent/Semaphore.java b/integration-test/src/main/java/org/apache/cassandra/utils/concurrent/Semaphore.java index b9525e3..9e78fc9 100644 --- a/integration-test/src/main/java/org/apache/cassandra/utils/concurrent/Semaphore.java +++ b/integration-test/src/main/java/org/apache/cassandra/utils/concurrent/Semaphore.java @@ -45,6 +45,7 @@ public interface Semaphore @Intercept static Semaphore newFairSemaphore(int permits) { return new Standard(permits, true); } + // nosemgrep: java.no-fqn -- JDK Semaphore conflicts with this interface class Standard extends java.util.concurrent.Semaphore implements Semaphore { private static final long serialVersionUID = 0L; diff --git a/integration-test/src/test/java/org/apache/cassandra/simulator_test/SchedulerIntegrationTest.java b/integration-test/src/test/java/org/apache/cassandra/simulator_test/SchedulerIntegrationTest.java index 54e28de..1295e2a 100644 --- a/integration-test/src/test/java/org/apache/cassandra/simulator_test/SchedulerIntegrationTest.java +++ b/integration-test/src/test/java/org/apache/cassandra/simulator_test/SchedulerIntegrationTest.java @@ -21,6 +21,8 @@ package org.apache.cassandra.simulator_test; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.ReentrantLock; import org.apache.cassandra.simulator.Simulator; import org.apache.cassandra.simulator.context.IIsolatedExecutor.SerializableRunnable; import org.apache.cassandra.simulator.systems.InterceptedWait.InterceptedConditionWait; @@ -80,8 +82,8 @@ public class SchedulerIntegrationTest /** Fallback non-simulated implementation used when not under simulation. */ class SimpleGate implements Gate { - private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); - private final java.util.concurrent.locks.Condition cond = lock.newCondition(); + private final ReentrantLock lock = new ReentrantLock(); + private final Condition cond = lock.newCondition(); private boolean opened = false; public void await() throws InterruptedException @@ -267,12 +269,12 @@ public class SchedulerIntegrationTest { try (Simulator sim = new Simulator(42L, 1.0f)) { - sim.intercept(java.util.concurrent.CountDownLatch.class, MyJdkCountDownLatch.class); + sim.intercept(CountDownLatch.class, MyJdkCountDownLatch.class); sim.simulate((SerializableRunnable) () -> { ArrayList<String> log = new ArrayList<>(); // new CountDownLatch(1) is redirected to new MyJdkCountDownLatch(1) - var latch = new java.util.concurrent.CountDownLatch(1); + var latch = new CountDownLatch(1); var done = cdl(2); new Thread(() -> { diff --git a/journal/src/main/java/org/apache/cassandra/io/util/File.java b/journal/src/main/java/org/apache/cassandra/io/util/File.java index 1de2ab7..a12dfcf 100644 --- a/journal/src/main/java/org/apache/cassandra/io/util/File.java +++ b/journal/src/main/java/org/apache/cassandra/io/util/File.java @@ -17,6 +17,7 @@ public class File private final Path path; public File(Path path) { this.path = path; } + // nosemgrep: java.no-fqn -- java.io.File conflicts with this class public File(java.io.File file) { this(file.toPath()); } public File(File parent, String child) { this(parent.path.resolve(child)); } @@ -31,6 +32,7 @@ public class File public void deleteRecursiveOnExit() { path.toFile().deleteOnExit(); } public void move(File to) { try { Files.move(path, to.path, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { try { Files.move(path, to.path, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e2) { throw new RuntimeException(e2); } } } public FileChannel newReadChannel() throws IOException { return FileChannel.open(path, StandardOpenOption.READ); } + // nosemgrep: java.no-fqn -- java.io.File conflicts with this class public String[] listNames(FilenameFilter filter) throws IOException { java.io.File[] files = path.toFile().listFiles((dir, name) -> filter.accept(dir, name)); if (files == null) return new String[0]; String[] names = new String[files.length]; for (int i=0;i<files.length;i++) names[i] = files[i].getName(); return names; } public List<File> listUnchecked(Predicate<File> predicate) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) { List<File> out = new ArrayList<>(); for (Path p : stream) { File f = new File(p); if (predicate.test(f)) out.add(f); } return out; } catch (IOException e) { throw new RuntimeException(e); } } @Override public String toString() { return path.toString(); } diff --git a/journal/src/main/java/org/apache/cassandra/io/util/PathUtils.java b/journal/src/main/java/org/apache/cassandra/io/util/PathUtils.java index 0a1ad42..97441d8 100644 --- a/journal/src/main/java/org/apache/cassandra/io/util/PathUtils.java +++ b/journal/src/main/java/org/apache/cassandra/io/util/PathUtils.java @@ -1,6 +1,8 @@ package org.apache.cassandra.io.util; import java.io.IOException; +import java.nio.file.FileStore; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileAttributeView; @@ -11,14 +13,14 @@ public final class PathUtils @FunctionalInterface public interface FileStoreToLong { - long applyAsLong(java.nio.file.FileStore fileStore) throws IOException; + long applyAsLong(FileStore fileStore) throws IOException; } public static long tryGetSpace(Path path, FileStoreToLong fn) { try { - return fn.applyAsLong(java.nio.file.Files.getFileStore(path)); + return fn.applyAsLong(Files.getFileStore(path)); } catch (Exception e) { diff --git a/journal/src/main/java/org/apache/cassandra/journal/Segment.java b/journal/src/main/java/org/apache/cassandra/journal/Segment.java index d387d64..cfa5f9c 100644 --- a/journal/src/main/java/org/apache/cassandra/journal/Segment.java +++ b/journal/src/main/java/org/apache/cassandra/journal/Segment.java @@ -1,16 +1,19 @@ package org.apache.cassandra.journal; import java.nio.ByteBuffer; +import java.util.concurrent.Executor; import accord.utils.Invariants; +import org.apache.cassandra.concurrent.ImmediateExecutor; import org.apache.cassandra.io.util.File; +import org.apache.cassandra.utils.concurrent.OpOrder; public abstract class Segment<K, V> implements Comparable<Segment<K, V>> { public static class Tidier implements Runnable { - public java.util.concurrent.Executor executor = org.apache.cassandra.concurrent.ImmediateExecutor.INSTANCE; - public org.apache.cassandra.utils.concurrent.OpOrder.Barrier await; + public Executor executor = ImmediateExecutor.INSTANCE; + public OpOrder.Barrier await; @Override public void run() diff --git a/journal/src/main/java/org/apache/cassandra/utils/Crc.java b/journal/src/main/java/org/apache/cassandra/utils/Crc.java index 197c553..a201d0e 100644 --- a/journal/src/main/java/org/apache/cassandra/utils/Crc.java +++ b/journal/src/main/java/org/apache/cassandra/utils/Crc.java @@ -1,11 +1,12 @@ package org.apache.cassandra.utils; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.zip.CRC32; public final class Crc { - public static class InvalidCrc extends java.io.IOException + public static class InvalidCrc extends IOException { public InvalidCrc(int read, int expected) { diff --git a/simulator-asm/src/main/java/org/apache/cassandra/simulator/asm/MonitorMethodTransformer.java b/simulator-asm/src/main/java/org/apache/cassandra/simulator/asm/MonitorMethodTransformer.java index a7c21bb..cbe6cd3 100644 --- a/simulator-asm/src/main/java/org/apache/cassandra/simulator/asm/MonitorMethodTransformer.java +++ b/simulator-asm/src/main/java/org/apache/cassandra/simulator/asm/MonitorMethodTransformer.java @@ -130,7 +130,7 @@ class MonitorMethodTransformer extends MethodNode void pushRef() { if (isInstanceMethod) instructions.add(new IntInsnNode(Opcodes.ALOAD, 0)); - else instructions.add(new LdcInsnNode(org.objectweb.asm.Type.getType('L' + className + ';'))); + else instructions.add(new LdcInsnNode(Type.getType('L' + className + ';'))); } void pop() diff --git a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassLoaderOwnershipTest.java b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassLoaderOwnershipTest.java index be3b384..37321fd 100644 --- a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassLoaderOwnershipTest.java +++ b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassLoaderOwnershipTest.java @@ -20,6 +20,7 @@ package org.apache.cassandra.simulator_test; import org.apache.cassandra.simulator.context.*; +import java.io.Serializable; import java.net.URL; import org.junit.jupiter.api.AfterEach; @@ -45,7 +46,7 @@ public class SimulationContextClassLoaderOwnershipTest /** Force-isolated counter — each context gets a separate copy with its own static field. */ @Isolated - public static class IsolatedCounter implements java.io.Serializable + public static class IsolatedCounter implements Serializable { public static int value = 0; } diff --git a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassRoutingTest.java b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassRoutingTest.java index a11193c..b292275 100644 --- a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassRoutingTest.java +++ b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextClassRoutingTest.java @@ -20,6 +20,7 @@ package org.apache.cassandra.simulator_test; import org.apache.cassandra.simulator.context.*; +import java.io.Serializable; import java.net.URL; import org.junit.jupiter.api.AfterEach; @@ -43,12 +44,12 @@ public class SimulationContextClassRoutingTest { // ── Fixtures ────────────────────────────────────────────────────────────── - public static class ForceIsolated implements java.io.Serializable {} + public static class ForceIsolated implements Serializable {} - public static class ForceShared implements java.io.Serializable {} + public static class ForceShared implements Serializable {} @Isolated - public static class AnnotatedIsolated implements java.io.Serializable {} + public static class AnnotatedIsolated implements Serializable {} private SimulationCluster<SimulationContext> cluster; diff --git a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextIntegrationTest.java b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextIntegrationTest.java index b572014..cb1afcd 100644 --- a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextIntegrationTest.java +++ b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextIntegrationTest.java @@ -21,6 +21,7 @@ package org.apache.cassandra.simulator_test; import org.apache.cassandra.simulator.context.*; import java.io.NotSerializableException; +import java.io.Serializable; import java.net.URL; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; @@ -45,13 +46,13 @@ public class SimulationContextIntegrationTest // ── Fixtures ────────────────────────────────────────────────────────────── @Isolated - public static class LocalCounter implements java.io.Serializable + public static class LocalCounter implements Serializable { public static int value = 0; } @Shared - public static class GlobalCounter implements java.io.Serializable + public static class GlobalCounter implements Serializable { public static final AtomicInteger value = new AtomicInteger(0); } diff --git a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextSharedClassTest.java b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextSharedClassTest.java index 4a038f8..9060347 100644 --- a/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextSharedClassTest.java +++ b/simulator-context/src/test/java/org/apache/cassandra/simulator_test/SimulationContextSharedClassTest.java @@ -20,6 +20,7 @@ package org.apache.cassandra.simulator_test; import org.apache.cassandra.simulator.context.*; +import java.io.Serializable; import java.net.URL; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; @@ -49,13 +50,13 @@ public class SimulationContextSharedClassTest // ── Fixtures ────────────────────────────────────────────────────────────── @Shared - public static class SharedCounter implements java.io.Serializable + public static class SharedCounter implements Serializable { public static final AtomicInteger value = new AtomicInteger(0); } /** Shared purely via the explicit sharedClasses[] list — no annotation. */ - public static class ExplicitlyShared implements java.io.Serializable + public static class ExplicitlyShared implements Serializable { public static int marker = 0; } diff --git a/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptingCountDownLatch.java b/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptingCountDownLatch.java index 6009924..0836799 100644 --- a/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptingCountDownLatch.java +++ b/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptingCountDownLatch.java @@ -18,13 +18,14 @@ package org.apache.cassandra.simulator.systems; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.cassandra.simulator.step.ObservableAction; @PerClassLoader -public class InterceptingCountDownLatch extends java.util.concurrent.CountDownLatch +public class InterceptingCountDownLatch extends CountDownLatch { private final InterceptingAwaitable.InterceptingCondition inner = new InterceptingAwaitable.InterceptingCondition(); private final AtomicInteger count; diff --git a/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptorOfGlobalMethods.java b/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptorOfGlobalMethods.java index e760f60..75b0625 100644 --- a/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptorOfGlobalMethods.java +++ b/simulator-core/src/main/java/org/apache/cassandra/simulator/systems/InterceptorOfGlobalMethods.java @@ -18,12 +18,16 @@ package org.apache.cassandra.simulator.systems; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.IntFunction; @@ -58,8 +62,8 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, ExecutorService newFixedThreadPool(int threads); ExecutorService newSingleThreadExecutor(); ExecutorService newCachedThreadPool(); - java.util.concurrent.ScheduledExecutorService newScheduledThreadPool(int threads); - java.util.concurrent.ScheduledExecutorService newSingleThreadScheduledExecutor(); + ScheduledExecutorService newScheduledThreadPool(int threads); + ScheduledExecutorService newSingleThreadScheduledExecutor(); /** * If this interceptor is debugging wait/wake/now sites, return one initialised with the current trace of the @@ -98,7 +102,7 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, Thread thread = Thread.currentThread(); if (thread instanceof InterceptibleThread) return ((InterceptibleThread) thread).interceptorOfGlobalMethods().newFixedThreadPool(threads); - return java.util.concurrent.Executors.newFixedThreadPool(threads); + return Executors.newFixedThreadPool(threads); } @Override @@ -107,7 +111,7 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, Thread thread = Thread.currentThread(); if (thread instanceof InterceptibleThread) return ((InterceptibleThread) thread).interceptorOfGlobalMethods().newSingleThreadExecutor(); - return java.util.concurrent.Executors.newSingleThreadExecutor(); + return Executors.newSingleThreadExecutor(); } @Override @@ -116,25 +120,25 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, Thread thread = Thread.currentThread(); if (thread instanceof InterceptibleThread) return ((InterceptibleThread) thread).interceptorOfGlobalMethods().newCachedThreadPool(); - return java.util.concurrent.Executors.newCachedThreadPool(); + return Executors.newCachedThreadPool(); } @Override - public java.util.concurrent.ScheduledExecutorService newScheduledThreadPool(int threads) + public ScheduledExecutorService newScheduledThreadPool(int threads) { Thread thread = Thread.currentThread(); if (thread instanceof InterceptibleThread) return ((InterceptibleThread) thread).interceptorOfGlobalMethods().newScheduledThreadPool(threads); - return java.util.concurrent.Executors.newScheduledThreadPool(threads); + return Executors.newScheduledThreadPool(threads); } @Override - public java.util.concurrent.ScheduledExecutorService newSingleThreadScheduledExecutor() + public ScheduledExecutorService newSingleThreadScheduledExecutor() { Thread thread = Thread.currentThread(); if (thread instanceof InterceptibleThread) return ((InterceptibleThread) thread).interceptorOfGlobalMethods().newSingleThreadScheduledExecutor(); - return java.util.concurrent.Executors.newSingleThreadScheduledExecutor(); + return Executors.newSingleThreadScheduledExecutor(); } @Override @@ -569,7 +573,7 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, private Entry<K, V>[] table; private int size; - private final java.lang.ref.ReferenceQueue<K> queue = new java.lang.ref.ReferenceQueue<>(); + private final ReferenceQueue<K> queue = new ReferenceQueue<>(); @SuppressWarnings("unchecked") WeakIdentityHashMap() @@ -577,13 +581,13 @@ public interface InterceptorOfGlobalMethods extends InterceptorOfSystemMethods, table = new Entry[DEFAULT_CAPACITY]; } - private static class Entry<K, V> extends java.lang.ref.WeakReference<K> + private static class Entry<K, V> extends WeakReference<K> { final int hash; V value; Entry<K, V> next; - Entry(K key, V value, java.lang.ref.ReferenceQueue<K> queue, int hash, Entry<K, V> next) + Entry(K key, V value, ReferenceQueue<K> queue, int hash, Entry<K, V> next) { super(key, queue); this.hash = hash; diff --git a/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Closeable.java b/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Closeable.java index bd5b6e4..f2c0dc9 100644 --- a/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Closeable.java +++ b/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Closeable.java @@ -18,6 +18,7 @@ package org.apache.cassandra.simulator.utils; +// nosemgrep: java.no-fqn -- java.io.Closeable conflicts with this interface public interface Closeable extends java.io.Closeable { void close(); } diff --git a/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Throwables.java b/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Throwables.java index a01b59f..41a1187 100644 --- a/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Throwables.java +++ b/simulator-core/src/main/java/org/apache/cassandra/simulator/utils/Throwables.java @@ -18,6 +18,7 @@ package org.apache.cassandra.simulator.utils; +import java.io.Closeable; import java.util.function.Consumer; import java.util.stream.Stream; @@ -56,9 +57,9 @@ public class Throwables { actions.forEach(a -> { try { a.run(); } catch (Throwable t) {} }); } - public static Throwable close(Throwable existing, java.io.Closeable... closeables) { return existing; } + public static Throwable close(Throwable existing, Closeable... closeables) { return existing; } - public static void closeNonNull(java.io.Closeable... closeables) {} + public static void closeNonNull(Closeable... closeables) {} public static Throwable perform(Throwable existing, Runnable action) { return existing; } diff --git a/simulator-core/src/test/java/org/apache/cassandra/simulator_test/SimulatorHostClassLoaderReproTest.java b/simulator-core/src/test/java/org/apache/cassandra/simulator_test/SimulatorHostClassLoaderReproTest.java index a51cbc5..faa13b9 100644 --- a/simulator-core/src/test/java/org/apache/cassandra/simulator_test/SimulatorHostClassLoaderReproTest.java +++ b/simulator-core/src/test/java/org/apache/cassandra/simulator_test/SimulatorHostClassLoaderReproTest.java @@ -26,6 +26,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; +import org.apache.cassandra.simulator.Simulator; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -71,7 +72,7 @@ public class SimulatorHostClassLoaderReproTest { public static void constructSimulator() { - new org.apache.cassandra.simulator.Simulator(42L).close(); + new Simulator(42L).close(); } } diff --git a/simulator-io/src/main/java/org/apache/cassandra/simulator/io/InstrumentedFile.java b/simulator-io/src/main/java/org/apache/cassandra/simulator/io/InstrumentedFile.java index eb43500..a3b144c 100644 --- a/simulator-io/src/main/java/org/apache/cassandra/simulator/io/InstrumentedFile.java +++ b/simulator-io/src/main/java/org/apache/cassandra/simulator/io/InstrumentedFile.java @@ -49,6 +49,7 @@ public class InstrumentedFile extends File super(path); } + // nosemgrep: java.no-fqn -- Cassandra File is already imported public InstrumentedFile(java.io.File file) { super(file); @@ -107,6 +108,7 @@ public class InstrumentedFile extends File public String[] listNames(FilenameFilter filter) throws IOException { ioStep(); + // nosemgrep: java.no-fqn -- Cassandra File is already imported java.io.File[] files = toPath().toFile().listFiles((dir, name) -> filter.accept(dir, name)); if (files == null) return new String[0]; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
