This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
The following commit(s) were added to refs/heads/master by this push:
new 5c97598 Use final.
5c97598 is described below
commit 5c975984aba6023116a2cc59b578588a4ee34379
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jul 10 09:35:59 2021 -0400
Use final.
Simplify expressions.
---
src/main/java/org/apache/commons/codec/digest/Blake3.java | 4 ++--
.../apache/commons/codec/binary/Base64InputStreamTest.java | 8 ++++----
src/test/java/org/apache/commons/codec/binary/HexTest.java | 4 ++--
.../java/org/apache/commons/codec/digest/Blake3Test.java | 4 ++--
.../apache/commons/codec/digest/Blake3TestVectorsTest.java | 14 +++++++-------
.../apache/commons/codec/language/DoubleMetaphoneTest.java | 4 ++--
6 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/Blake3.java
b/src/main/java/org/apache/commons/codec/digest/Blake3.java
index 5cc6909..d816277 100644
--- a/src/main/java/org/apache/commons/codec/digest/Blake3.java
+++ b/src/main/java/org/apache/commons/codec/digest/Blake3.java
@@ -252,7 +252,7 @@ public final class Blake3 {
return blake3.doFinalize(OUT_LEN);
}
- private static void checkBufferArgs(byte[] buffer, int offset, int length)
{
+ private static void checkBufferArgs(final byte[] buffer, final int offset,
final int length) {
Objects.requireNonNull(buffer);
if (offset < 0) {
throw new IndexOutOfBoundsException("Offset must be non-negative");
@@ -260,7 +260,7 @@ public final class Blake3 {
if (length < 0) {
throw new IndexOutOfBoundsException("Length must be non-negative");
}
- int bufferLength = buffer.length;
+ final int bufferLength = buffer.length;
if (offset > bufferLength - length) {
throw new IndexOutOfBoundsException(
"Offset " + offset + " and length " + length + " out of
bounds with buffer length " + bufferLength);
diff --git
a/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
b/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
index cdbfc7c..64e208f 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
@@ -417,14 +417,14 @@ public class Base64InputStreamTest {
@Test
public void testReadMultipleBufferSizes() throws Exception {
final byte[][] randomData = BaseNTestData.randomData(new Base64(0,
null, false), 1024 * 64);
- byte[] encoded = randomData[1];
- byte[] decoded = randomData[0];
+ final byte[] encoded = randomData[1];
+ final byte[] decoded = randomData[0];
final ByteArrayInputStream bin = new ByteArrayInputStream(encoded);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try (final Base64InputStream in = new Base64InputStream(bin)) {
- for (int i : new int[] { 4 * 1024, 4 * 1024, 8 * 1024, 8 * 1024,
16 * 1024, 16 * 1024, 8 * 1024 }) {
+ for (final int i : new int[] { 4 * 1024, 4 * 1024, 8 * 1024, 8 *
1024, 16 * 1024, 16 * 1024, 8 * 1024 }) {
final byte[] buf = new byte[i];
- int bytesRead = in.read(buf);
+ final int bytesRead = in.read(buf);
assertEquals(i, bytesRead);
out.write(buf, 0, bytesRead);
}
diff --git a/src/test/java/org/apache/commons/codec/binary/HexTest.java
b/src/test/java/org/apache/commons/codec/binary/HexTest.java
index 4bfcd67..4f4cb31 100644
--- a/src/test/java/org/apache/commons/codec/binary/HexTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/HexTest.java
@@ -81,7 +81,7 @@ public class HexTest {
final byte[] bytes = source.getBytes(name);
final String str = new String(bytes, name);
final boolean equals = source.equals(str);
- if (equals == false) {
+ if (!equals) {
// Here with:
//
// Java Sun 1.4.2_19 x86 32-bits on Windows XP
@@ -174,7 +174,7 @@ public class HexTest {
*/
private void testCustomCharset(final String name, final String parent)
throws UnsupportedEncodingException,
DecoderException {
- if (charsetSanityCheck(name) == false) {
+ if (!charsetSanityCheck(name)) {
return;
}
log(parent + "=" + name);
diff --git a/src/test/java/org/apache/commons/codec/digest/Blake3Test.java
b/src/test/java/org/apache/commons/codec/digest/Blake3Test.java
index d4448a6..1e8ee2d 100644
--- a/src/test/java/org/apache/commons/codec/digest/Blake3Test.java
+++ b/src/test/java/org/apache/commons/codec/digest/Blake3Test.java
@@ -30,11 +30,11 @@ public class Blake3Test {
assertThrowsProperExceptionWithKeySize(33);
}
- private static void assertThrowsProperExceptionWithKeySize(int keySize) {
+ private static void assertThrowsProperExceptionWithKeySize(final int
keySize) {
try {
Blake3.initKeyedHash(new byte[keySize]);
fail("Should have thrown exception");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
assertEquals("Blake3 keys must be 32 bytes",
expected.getMessage());
}
}
diff --git
a/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
b/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
index c05f92e..609547c 100644
--- a/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
@@ -267,7 +267,7 @@ public class Blake3TestVectorsTest {
private final byte[] keyedHash;
private final byte[] deriveKey;
- public Blake3TestVectorsTest(int inputLength, String hash, String
keyedHash, String deriveKey)
+ public Blake3TestVectorsTest(final int inputLength, final String hash,
final String keyedHash, final String deriveKey)
throws DecoderException {
input = new byte[inputLength];
for (int i = 0; i < input.length; i++) {
@@ -281,37 +281,37 @@ public class Blake3TestVectorsTest {
@Test
public void hashArbitraryOutputLength() {
hasher.update(input);
- byte[] actual = hasher.doFinalize(hash.length);
+ final byte[] actual = hasher.doFinalize(hash.length);
assertArrayEquals(hash, actual);
}
@Test
public void hashTruncatedOutput() {
- byte[] actual = Blake3.hash(input);
+ final byte[] actual = Blake3.hash(input);
assertArrayEquals(Arrays.copyOf(this.hash, 32), actual);
}
@Test
public void keyedHashArbitraryOutputLength() {
keyedHasher.update(input);
- byte[] actual = keyedHasher.doFinalize(keyedHash.length);
+ final byte[] actual = keyedHasher.doFinalize(keyedHash.length);
assertArrayEquals(keyedHash, actual);
}
@Test
public void keyedHashTruncatedOutput() {
- byte[] actual = Blake3.keyedHash(KEY, input);
+ final byte[] actual = Blake3.keyedHash(KEY, input);
assertArrayEquals(Arrays.copyOf(keyedHash, 32), actual);
}
@Test
public void keyDerivation() {
kdfHasher.update(input);
- byte[] actual = kdfHasher.doFinalize(deriveKey.length);
+ final byte[] actual = kdfHasher.doFinalize(deriveKey.length);
assertArrayEquals(deriveKey, actual);
kdfHasher.reset();
kdfHasher.update(input);
- byte[] truncated = kdfHasher.doFinalize(32);
+ final byte[] truncated = kdfHasher.doFinalize(32);
assertArrayEquals(Arrays.copyOf(deriveKey, 32), truncated);
}
}
diff --git
a/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
b/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
index 12844b1..5dc8a3c 100644
--- a/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
+++ b/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
@@ -1172,7 +1172,7 @@ public class DoubleMetaphoneTest extends
StringEncoderAbstractTest<DoubleMetapho
final String name1 = FIXTURE[i][1];
final boolean match1 =
this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
final boolean match2 =
this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
- if (match1 == false && match2 == false) {
+ if (!match1 && !match2) {
final String failMsg = "[" + i + "] " + name0 + " and " +
name1 + cr;
failures.append(failMsg);
failCount++;
@@ -1199,7 +1199,7 @@ public class DoubleMetaphoneTest extends
StringEncoderAbstractTest<DoubleMetapho
final String name1 = MATCHES[i][1];
final boolean match1 =
this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, false);
final boolean match2 =
this.getStringEncoder().isDoubleMetaphoneEqual(name0, name1, true);
- if (match1 == false && match2 == false) {
+ if (!match1 && !match2) {
fail("Expected match [" + i + "] " + name0 + " and " + name1);
}
}