From ee2f2b04edc5b8cf575634a6b48deaaa2b9e0e84 Mon Sep 17 00:00:00 2001 From: Jason Dahlke Date: Fri, 23 Aug 2024 15:12:22 +0000 Subject: [PATCH] errorprone :: FieldCanBeFinal --- src/main/java/emissary/admin/Startup.java | 2 +- src/main/java/emissary/client/EmissaryClient.java | 4 ++-- .../emissary/command/converter/FileExistsConverter.java | 2 +- .../emissary/command/converter/PathExistsConverter.java | 2 +- src/main/java/emissary/core/DiffCheckConfiguration.java | 2 +- .../emissary/core/channels/InputStreamChannelFactory.java | 2 +- src/main/java/emissary/kff/ChecksumCalculator.java | 2 +- src/main/java/emissary/kff/KffFile.java | 2 +- src/main/java/emissary/kff/KffMemcached.java | 2 +- src/main/java/emissary/kff/SpamSumSignature.java | 4 ++-- src/main/java/emissary/output/filter/JsonOutputFilter.java | 2 +- .../java/emissary/output/io/SimpleFileNameGenerator.java | 2 +- .../java/emissary/output/roller/JournaledCoalescer.java | 2 +- src/main/java/emissary/util/CaseInsensitiveMap.java | 2 +- src/main/java/emissary/util/UnixFile.java | 4 ++-- src/main/java/emissary/util/io/FileFind.java | 4 ++-- src/main/java/emissary/util/io/ReadOutput.java | 4 ++-- .../java/emissary/util/roll/RollableFileOutputStream.java | 2 +- src/main/java/emissary/util/search/ByteTokenizer.java | 6 +++--- src/main/java/emissary/util/search/KeywordScanner.java | 2 +- src/main/java/emissary/util/search/MultiKeywordScanner.java | 2 +- 21 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/emissary/admin/Startup.java b/src/main/java/emissary/admin/Startup.java index f25a87a58a..289969c40a 100755 --- a/src/main/java/emissary/admin/Startup.java +++ b/src/main/java/emissary/admin/Startup.java @@ -46,7 +46,7 @@ public class Startup { static int directoryAction = DIRECTORYADD; // If we are an emissary node these will be present - private EmissaryNode node; + private final EmissaryNode node; // Our logger private static final Logger logger = LoggerFactory.getLogger(Startup.class); diff --git a/src/main/java/emissary/client/EmissaryClient.java b/src/main/java/emissary/client/EmissaryClient.java index 4b53e73ae4..ea2abe5cbe 100644 --- a/src/main/java/emissary/client/EmissaryClient.java +++ b/src/main/java/emissary/client/EmissaryClient.java @@ -82,8 +82,8 @@ public class EmissaryClient { // class is thread-safe protected static final AuthCache AUTH_CACHE = new BasicAuthCache(); - private CloseableHttpClient client; - private RequestConfig requestConfig; + private final CloseableHttpClient client; + private final RequestConfig requestConfig; private ConnectionConfig connectionConfig; static { diff --git a/src/main/java/emissary/command/converter/FileExistsConverter.java b/src/main/java/emissary/command/converter/FileExistsConverter.java index 73ab0774be..1a85fa73bb 100644 --- a/src/main/java/emissary/command/converter/FileExistsConverter.java +++ b/src/main/java/emissary/command/converter/FileExistsConverter.java @@ -11,7 +11,7 @@ import javax.annotation.Nullable; public class FileExistsConverter implements ITypeConverter { - private String optionName; + private final String optionName; private static final Logger LOG = LoggerFactory.getLogger(FileExistsConverter.class); public FileExistsConverter() { diff --git a/src/main/java/emissary/command/converter/PathExistsConverter.java b/src/main/java/emissary/command/converter/PathExistsConverter.java index 604719f936..57b92d3ad0 100644 --- a/src/main/java/emissary/command/converter/PathExistsConverter.java +++ b/src/main/java/emissary/command/converter/PathExistsConverter.java @@ -11,7 +11,7 @@ import javax.annotation.Nullable; public class PathExistsConverter implements ITypeConverter { - private String optionName; + private final String optionName; public PathExistsConverter() { this(null); diff --git a/src/main/java/emissary/core/DiffCheckConfiguration.java b/src/main/java/emissary/core/DiffCheckConfiguration.java index 1d1323d0e3..546794ec69 100644 --- a/src/main/java/emissary/core/DiffCheckConfiguration.java +++ b/src/main/java/emissary/core/DiffCheckConfiguration.java @@ -119,7 +119,7 @@ public static class DiffCheckBuilder { /** * Internal state whilst building */ - private EnumSet building; + private final EnumSet building; /** * Finish building and create the final DiffCheckConfiguration object diff --git a/src/main/java/emissary/core/channels/InputStreamChannelFactory.java b/src/main/java/emissary/core/channels/InputStreamChannelFactory.java index 929a7cc636..1a5f36266a 100644 --- a/src/main/java/emissary/core/channels/InputStreamChannelFactory.java +++ b/src/main/java/emissary/core/channels/InputStreamChannelFactory.java @@ -26,7 +26,7 @@ public static SeekableByteChannelFactory create(final long size, final InputStre } private static class InputStreamChannelFactoryImpl implements SeekableByteChannelFactory { - private long size; + private final long size; private final InputStreamFactory inputStreamFactory; public InputStreamChannelFactoryImpl(final long size, final InputStreamFactory inputStreamFactory) { diff --git a/src/main/java/emissary/kff/ChecksumCalculator.java b/src/main/java/emissary/kff/ChecksumCalculator.java index 18a8b65777..c7c8847c2a 100755 --- a/src/main/java/emissary/kff/ChecksumCalculator.java +++ b/src/main/java/emissary/kff/ChecksumCalculator.java @@ -30,7 +30,7 @@ public class ChecksumCalculator { private Ssdeep ssdeep = null; /** Used for hash calculations */ - private List digest = new ArrayList<>(); + private final List digest = new ArrayList<>(); /** * Constructor initializes SHA-1 generator and turns on the CRC32 processing as well diff --git a/src/main/java/emissary/kff/KffFile.java b/src/main/java/emissary/kff/KffFile.java index 10c32e0f69..61cd66e909 100755 --- a/src/main/java/emissary/kff/KffFile.java +++ b/src/main/java/emissary/kff/KffFile.java @@ -35,7 +35,7 @@ public class KffFile implements KffFilter { protected ByteBuffer mappedBuf; /** Initial value of high index for binary search */ - private long bSearchInitHigh; + private final long bSearchInitHigh; public static final int DEFAULT_RECORD_LENGTH = 24; protected final int recordLength; diff --git a/src/main/java/emissary/kff/KffMemcached.java b/src/main/java/emissary/kff/KffMemcached.java index 8ec724605c..3ed4230f29 100644 --- a/src/main/java/emissary/kff/KffMemcached.java +++ b/src/main/java/emissary/kff/KffMemcached.java @@ -46,7 +46,7 @@ public class KffMemcached implements KffFilter { /** * Logger */ - private Logger logger; + private final Logger logger; /** * The hash to use as the key diff --git a/src/main/java/emissary/kff/SpamSumSignature.java b/src/main/java/emissary/kff/SpamSumSignature.java index fc908f8fe9..ce9797ee34 100644 --- a/src/main/java/emissary/kff/SpamSumSignature.java +++ b/src/main/java/emissary/kff/SpamSumSignature.java @@ -13,8 +13,8 @@ public class SpamSumSignature { * FIELDS *****************************************************/ private/* uint */long blockSize; - private byte[] hash1; - private byte[] hash2; + private final byte[] hash1; + private final byte[] hash2; /***************************************************** * UTILS diff --git a/src/main/java/emissary/output/filter/JsonOutputFilter.java b/src/main/java/emissary/output/filter/JsonOutputFilter.java index 080fe96b66..7793571519 100644 --- a/src/main/java/emissary/output/filter/JsonOutputFilter.java +++ b/src/main/java/emissary/output/filter/JsonOutputFilter.java @@ -102,7 +102,7 @@ class IbdoParameterFilter extends SimpleBeanPropertyFilter { protected final boolean denylistStar; protected final boolean emptyAllowlist; protected final boolean allowlistStar; - private char keyReplacement = '_'; + private final char keyReplacement = '_'; public IbdoParameterFilter() { // if all collections are empty, then output everything diff --git a/src/main/java/emissary/output/io/SimpleFileNameGenerator.java b/src/main/java/emissary/output/io/SimpleFileNameGenerator.java index 959dbf5441..f524657018 100644 --- a/src/main/java/emissary/output/io/SimpleFileNameGenerator.java +++ b/src/main/java/emissary/output/io/SimpleFileNameGenerator.java @@ -4,7 +4,7 @@ import emissary.util.io.FileNameGenerator; public class SimpleFileNameGenerator implements FileNameGenerator { - private DropOffUtil dropOffUtil; + private final DropOffUtil dropOffUtil; /** * Creates a file name generator for BUD files diff --git a/src/main/java/emissary/output/roller/JournaledCoalescer.java b/src/main/java/emissary/output/roller/JournaledCoalescer.java index 80e72623bf..f13bf0746c 100644 --- a/src/main/java/emissary/output/roller/JournaledCoalescer.java +++ b/src/main/java/emissary/output/roller/JournaledCoalescer.java @@ -58,7 +58,7 @@ public class JournaledCoalescer implements IJournaler, ICoalescer { /** * The name generator to use when creating new output files * */ - private FileNameGenerator fileNameGenerator; + private final FileNameGenerator fileNameGenerator; /** * The path to read input and write rolled output * */ diff --git a/src/main/java/emissary/util/CaseInsensitiveMap.java b/src/main/java/emissary/util/CaseInsensitiveMap.java index 33ea3d03eb..a101ac357d 100755 --- a/src/main/java/emissary/util/CaseInsensitiveMap.java +++ b/src/main/java/emissary/util/CaseInsensitiveMap.java @@ -11,7 +11,7 @@ public class CaseInsensitiveMap extends HashMap { static final long serialVersionUID = -8692638820306464417L; // For remapping string keys to through a case-insensitive layer - private Map remap = new HashMap<>(); + private final Map remap = new HashMap<>(); /** * Create one diff --git a/src/main/java/emissary/util/UnixFile.java b/src/main/java/emissary/util/UnixFile.java index 6b45407853..d327f4ff56 100644 --- a/src/main/java/emissary/util/UnixFile.java +++ b/src/main/java/emissary/util/UnixFile.java @@ -17,10 +17,10 @@ public class UnixFile { private static final Logger log = LoggerFactory.getLogger(UnixFile.class); /** The magic number configuration file. The file which contains all magic number entries */ - private List magicFiles = new ArrayList<>(); + private final List magicFiles = new ArrayList<>(); /** The Magic number helper class */ - private MagicNumberUtil util = new MagicNumberUtil(); + private final MagicNumberUtil util = new MagicNumberUtil(); /** The Binary file type description */ public static final String FILETYPE_BINARY = "Binary File"; diff --git a/src/main/java/emissary/util/io/FileFind.java b/src/main/java/emissary/util/io/FileFind.java index 8d754cc322..56d0a39420 100755 --- a/src/main/java/emissary/util/io/FileFind.java +++ b/src/main/java/emissary/util/io/FileFind.java @@ -93,7 +93,7 @@ class FileIterator implements Iterator { /** * Stack of Files and directory lists keeping track of where in the tree we are. */ - private Deque currentPath = new ArrayDeque<>(); + private final Deque currentPath = new ArrayDeque<>(); @Nullable private FileFilter filter = null; @@ -178,7 +178,7 @@ private void findNextFile() { * the added complexity of the 'Iterator' class. */ static class DirectoryList { - private File[] contents; + private final File[] contents; private int position; public DirectoryList(File[] contents) { diff --git a/src/main/java/emissary/util/io/ReadOutput.java b/src/main/java/emissary/util/io/ReadOutput.java index 9e9be1f494..f7f04d0fb1 100755 --- a/src/main/java/emissary/util/io/ReadOutput.java +++ b/src/main/java/emissary/util/io/ReadOutput.java @@ -15,10 +15,10 @@ public class ReadOutput implements Runnable { - private BufferedReader br; + private final BufferedReader br; @Nullable private PrintStream ps = null; - private String tag; + private final String tag; public boolean finished = false; public ReadOutput(InputStream is, String str) { diff --git a/src/main/java/emissary/util/roll/RollableFileOutputStream.java b/src/main/java/emissary/util/roll/RollableFileOutputStream.java index 499ea9927b..e2a5c40d28 100644 --- a/src/main/java/emissary/util/roll/RollableFileOutputStream.java +++ b/src/main/java/emissary/util/roll/RollableFileOutputStream.java @@ -36,7 +36,7 @@ public class RollableFileOutputStream extends OutputStream implements Rollable { /** File Name Generator for creating unique file names */ FileNameGenerator namegen; /** Directory we're writing to */ - private File dir; + private final File dir; /** Number of bytes written to file */ long bytesWritten; /** Whether to delete a zero byte file */ diff --git a/src/main/java/emissary/util/search/ByteTokenizer.java b/src/main/java/emissary/util/search/ByteTokenizer.java index b9efe98bb6..2ca1e082a1 100755 --- a/src/main/java/emissary/util/search/ByteTokenizer.java +++ b/src/main/java/emissary/util/search/ByteTokenizer.java @@ -22,10 +22,10 @@ public class ByteTokenizer implements Iterator { private int currentPosition; private int newPosition; - private int maxPosition; - private byte[] data; + private final int maxPosition; + private final byte[] data; private String delimiters; - private boolean retDelims; + private final boolean retDelims; private boolean delimsChanged; private String encoding; diff --git a/src/main/java/emissary/util/search/KeywordScanner.java b/src/main/java/emissary/util/search/KeywordScanner.java index 0572e8bf86..845df1c3ae 100755 --- a/src/main/java/emissary/util/search/KeywordScanner.java +++ b/src/main/java/emissary/util/search/KeywordScanner.java @@ -8,7 +8,7 @@ * Provides the ability to find specified {@code byte[]} patterns inside a larger {@code byte[]}. */ public class KeywordScanner { - private int[] skip = new int[256]; + private final int[] skip = new int[256]; private int dataLength = -1; private byte[] data; private byte[] pattern; diff --git a/src/main/java/emissary/util/search/MultiKeywordScanner.java b/src/main/java/emissary/util/search/MultiKeywordScanner.java index c7c3a708af..a340d8237b 100755 --- a/src/main/java/emissary/util/search/MultiKeywordScanner.java +++ b/src/main/java/emissary/util/search/MultiKeywordScanner.java @@ -11,7 +11,7 @@ public class MultiKeywordScanner implements IMultiKeywordScanner { @Nullable private byte[] data = null; - private int[] skipTable = new int[256]; + private final int[] skipTable = new int[256]; private int standardSkip = 0; private BackwardsTreeScanner treeScanner; private String[] keywords;