Fix newly detected violations from PMD 7

This commit is contained in:
Manuel Fuhr 2024-04-03 14:41:06 +02:00
parent 2f7ce42480
commit dd896347a2
28 changed files with 65 additions and 57 deletions

View file

@ -9,6 +9,7 @@ import java.util.List;
*
* @author ab
*/
@SuppressWarnings("PMD.LooseCoupling")
public class LazyArrayOfLists<E> {
private List<ArrayList<E>> lists;

View file

@ -51,12 +51,12 @@ public class StackSampler extends Thread {
try {
int wait1 = rand.nextInt(interval);
int wait2 = interval - wait1;
Thread.sleep(wait1);
sleep(wait1);
StringBuilder sb = new StringBuilder(df.format(new Date()) + " THREADDUMP\n");
Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();
Map<Thread, StackTraceElement[]> allThreads = getAllStackTraces();
for (Map.Entry<Thread, StackTraceElement[]> e : allThreads.entrySet()) {
Thread t = e.getKey();
if (t == Thread.currentThread()) {
if (t == currentThread()) {
continue; // not me
}
@ -76,7 +76,7 @@ public class StackSampler extends Thread {
flushCnt = 0;
bw.flush();
}
Thread.sleep(wait2);
sleep(wait2);
} catch (Exception e) {
// ignore
}

View file

@ -4,6 +4,7 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class CompactMapTest {
@ -22,7 +23,7 @@ public class CompactMapTest {
private void hashMapComparison(int mapsize, int trycount) {
Random rand = new Random(12345);
HashMap<Long, String> hmap = new HashMap<>();
Map<Long, String> hmap = new HashMap<>();
CompactLongMap<String> cmap_slow = new CompactLongMap<>();
CompactLongMap<String> cmap_fast = new CompactLongMap<>();

View file

@ -5,6 +5,7 @@ import org.junit.Test;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class CompactSetTest {
@Test
@ -22,7 +23,7 @@ public class CompactSetTest {
private void hashSetComparison(int setsize, int trycount) {
Random rand = new Random(12345);
HashSet<Long> hset = new HashSet<>();
Set<Long> hset = new HashSet<>();
CompactLongSet cset_slow = new CompactLongSet();
CompactLongSet cset_fast = new CompactLongSet();

View file

@ -5,7 +5,9 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
public class DenseLongMapTest {
@Test
@ -16,7 +18,7 @@ public class DenseLongMapTest {
private void hashMapComparison(int mapsize, int trycount, long keyrange) {
Random rand = new Random(12345);
HashMap<Long, Integer> hmap = new HashMap<>();
Map<Long, Integer> hmap = new HashMap<>();
DenseLongMap dmap = new DenseLongMap(512);
for (int i = 0; i < mapsize; i++) {
@ -48,7 +50,7 @@ public class DenseLongMapTest {
int trycount = 100000;
Random rand = new Random(12345);
HashSet<Long> hset = new HashSet<>();
Set<Long> hset = new HashSet<>();
DenseLongMap dmap = new DenseLongMap(512);
for (int i = 0; i < mapputs; i++) {