From 33f8d1a25828918056799b3ee96c519f990cc234 Mon Sep 17 00:00:00 2001
From: Davide Angelocola
Date: Fri, 19 Feb 2021 21:14:31 +0100
Subject: [PATCH] minor fixes
- fix possible overflow in test
- unused imports
- javadoc
---
core/src/main/java/org/jboss/logmanager/AtomicArray.java | 6 +++---
.../org/jboss/logmanager/ClassLoaderLogContextSelector.java | 1 -
.../java/org/jboss/logmanager/filters/SubstituteFilter.java | 4 ++--
.../java/org/jboss/logmanager/formatters/Formatters.java | 2 +-
core/src/test/java/org/jboss/logmanager/FilterTests.java | 3 ---
core/src/test/java/org/jboss/logmanager/LoggerTests.java | 1 -
.../logmanager/ext/formatters/StructuredFormatter.java | 3 +--
.../org/jboss/logmanager/ext/handlers/TcpOutputStream.java | 2 +-
.../jboss/logmanager/ext/handlers/AbstractHandlerTest.java | 6 +++---
.../jboss/logmanager/ext/handlers/SocketHandlerTests.java | 2 +-
10 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/core/src/main/java/org/jboss/logmanager/AtomicArray.java b/core/src/main/java/org/jboss/logmanager/AtomicArray.java
index 9f90ace5..b03582b5 100644
--- a/core/src/main/java/org/jboss/logmanager/AtomicArray.java
+++ b/core/src/main/java/org/jboss/logmanager/AtomicArray.java
@@ -159,7 +159,7 @@ public boolean addIfAbsent(T instance, V value, boolean identity) {
}
/**
- * Atomically replace the array with a new array which does not include the first occurrance of the given value, if
+ * Atomically replace the array with a new array which does not include the first occurrence of the given value, if
* the value is present in the array.
*
* @param instance the instance holding the field
@@ -205,7 +205,7 @@ public boolean remove(T instance, V value, boolean identity) {
}
/**
- * Atomically replace the array with a new array which does not include any occurrances of the given value, if
+ * Atomically replace the array with a new array which does not include any occurrences of the given value, if
* the value is present in the array.
*
* @param instance the instance holding the field
@@ -310,7 +310,7 @@ public boolean addIfAbsent(T instance, V value, Comparator super V> comparator
}
/**
- * Remove a value to a sorted array. Does not check for duplicates. If there are multiple occurrances of a value,
+ * Remove a value to a sorted array. Does not check for duplicates. If there are multiple occurrences of a value,
* there is no guarantee as to which one is removed.
*
* @param instance the instance holding the field
diff --git a/core/src/main/java/org/jboss/logmanager/ClassLoaderLogContextSelector.java b/core/src/main/java/org/jboss/logmanager/ClassLoaderLogContextSelector.java
index 9ba6d8d1..4a7f2a41 100644
--- a/core/src/main/java/org/jboss/logmanager/ClassLoaderLogContextSelector.java
+++ b/core/src/main/java/org/jboss/logmanager/ClassLoaderLogContextSelector.java
@@ -22,7 +22,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.Permission;
-import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
diff --git a/core/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java b/core/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java
index ff01b196..f7ac43f6 100644
--- a/core/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java
+++ b/core/src/main/java/org/jboss/logmanager/filters/SubstituteFilter.java
@@ -43,7 +43,7 @@ public final class SubstituteFilter implements Filter {
*
* @param pattern the pattern to match
* @param replacement the string replacement
- * @param replaceAll {@code true} if all occurrances should be replaced; {@code false} if only the first occurrance
+ * @param replaceAll {@code true} if all occurrences should be replaced; {@code false} if only the first occurrence
*/
public SubstituteFilter(final Pattern pattern, final String replacement, final boolean replaceAll) {
this.pattern = pattern;
@@ -56,7 +56,7 @@ public SubstituteFilter(final Pattern pattern, final String replacement, final b
*
* @param patternString the pattern to match
* @param replacement the string replacement
- * @param replaceAll {@code true} if all occurrances should be replaced; {@code false} if only the first occurrance
+ * @param replaceAll {@code true} if all occurrences should be replaced; {@code false} if only the first occurrence
*/
public SubstituteFilter(final String patternString, final String replacement, final boolean replaceAll) {
this(Pattern.compile(patternString), replacement, replaceAll);
diff --git a/core/src/main/java/org/jboss/logmanager/formatters/Formatters.java b/core/src/main/java/org/jboss/logmanager/formatters/Formatters.java
index 0f677e45..d573a7f3 100644
--- a/core/src/main/java/org/jboss/logmanager/formatters/Formatters.java
+++ b/core/src/main/java/org/jboss/logmanager/formatters/Formatters.java
@@ -576,7 +576,7 @@ public static FormatStep hostnameFormatStep(final boolean leftJustify, final int
public String getSegmentedSubject(final ExtLogRecord record) {
final String hostName = record.getHostName();
// Check for a specified precision. This is not passed to the constructor because we want truncate
- // segments from the right intsead of the left.
+ // segments from the right instead of the left.
if (precision != null && PRECISION_INT_PATTERN.matcher(precision).matches()) {
int count = Integer.parseInt(precision);
int end = 0;
diff --git a/core/src/test/java/org/jboss/logmanager/FilterTests.java b/core/src/test/java/org/jboss/logmanager/FilterTests.java
index 06f180de..3f006439 100644
--- a/core/src/test/java/org/jboss/logmanager/FilterTests.java
+++ b/core/src/test/java/org/jboss/logmanager/FilterTests.java
@@ -20,7 +20,6 @@
package org.jboss.logmanager;
import org.jboss.logmanager.ExtLogRecord.FormatStyle;
-import org.jboss.logmanager.formatters.PatternFormatter;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -35,9 +34,7 @@
import org.jboss.logmanager.filters.RegexFilter;
import org.jboss.logmanager.filters.SubstituteFilter;
-import java.util.logging.ErrorManager;
import java.util.logging.Filter;
-import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
diff --git a/core/src/test/java/org/jboss/logmanager/LoggerTests.java b/core/src/test/java/org/jboss/logmanager/LoggerTests.java
index f7c81c0d..b1ff6fcf 100644
--- a/core/src/test/java/org/jboss/logmanager/LoggerTests.java
+++ b/core/src/test/java/org/jboss/logmanager/LoggerTests.java
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.logging.Filter;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
diff --git a/ext/src/main/java/org/jboss/logmanager/ext/formatters/StructuredFormatter.java b/ext/src/main/java/org/jboss/logmanager/ext/formatters/StructuredFormatter.java
index f4c21fb5..e57063ef 100644
--- a/ext/src/main/java/org/jboss/logmanager/ext/formatters/StructuredFormatter.java
+++ b/ext/src/main/java/org/jboss/logmanager/ext/formatters/StructuredFormatter.java
@@ -23,7 +23,6 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
-import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.IdentityHashMap;
@@ -623,7 +622,7 @@ default Generator add(final String key, final long value) throws Exception {
* By default this processes the map and uses {@link #add(String, String)} to add entries.
*
*
- * @param metaData the matp of the meta data, cannot be {@code null}
+ * @param metaData the map of the meta data, cannot be {@code null}
*
* @return the generator
*
diff --git a/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java b/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java
index 15a6336f..772fc6d5 100644
--- a/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java
+++ b/ext/src/main/java/org/jboss/logmanager/ext/handlers/TcpOutputStream.java
@@ -373,7 +373,7 @@ public void run() {
addError(e);
final long timeout;
if (attempts++ > 0L) {
- timeout = (10 * attempts);
+ timeout = (10L * attempts);
} else {
timeout = retryTimeout;
}
diff --git a/ext/src/test/java/org/jboss/logmanager/ext/handlers/AbstractHandlerTest.java b/ext/src/test/java/org/jboss/logmanager/ext/handlers/AbstractHandlerTest.java
index d1fae457..0261563c 100644
--- a/ext/src/test/java/org/jboss/logmanager/ext/handlers/AbstractHandlerTest.java
+++ b/ext/src/test/java/org/jboss/logmanager/ext/handlers/AbstractHandlerTest.java
@@ -172,8 +172,8 @@ static void compareArchiveContents(final Path archive1, final Path archive2, fin
lines1 = readAllLinesFromZip(archive1, expectedFileName);
lines2 = readAllLinesFromZip(archive2, expectedFileName);
} else if (archive1.getFileName().toString().endsWith(".gz")) {
- lines1 = readAllLinesFromGzip(archive1, expectedFileName);
- lines2 = readAllLinesFromGzip(archive2, expectedFileName);
+ lines1 = readAllLinesFromGzip(archive1);
+ lines2 = readAllLinesFromGzip(archive2);
} else {
Assert.fail(String.format("Files %s and %s are not archives.", archive1, archive2));
}
@@ -211,7 +211,7 @@ private static Collection readAllLinesFromZip(final Path path, final Str
}
}
- private static Collection readAllLinesFromGzip(final Path path, final String expectedFileName) throws IOException {
+ private static Collection readAllLinesFromGzip(final Path path) throws IOException {
final Collection lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(Files.newInputStream(path))))) {
String line;
diff --git a/ext/src/test/java/org/jboss/logmanager/ext/handlers/SocketHandlerTests.java b/ext/src/test/java/org/jboss/logmanager/ext/handlers/SocketHandlerTests.java
index 77945516..7f6ea53d 100644
--- a/ext/src/test/java/org/jboss/logmanager/ext/handlers/SocketHandlerTests.java
+++ b/ext/src/test/java/org/jboss/logmanager/ext/handlers/SocketHandlerTests.java
@@ -218,7 +218,7 @@ private SocketHandler createHandler(final Protocol protocol) throws UnsupportedE
private static R timeout(final Supplier supplier, final int timeout) throws InterruptedException {
R value = null;
- long t = timeout * 1000;
+ long t = timeout * 1000L;
final long sleep = 100L;
while (t > 0) {
final long before = System.currentTimeMillis();