[commons-dbutils] branch master updated: Update to latest commons-parent pom
This is an automated email from the ASF dual-hosted git repository. thecarlhall pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git The following commit(s) were added to refs/heads/master by this push: new 430753d Update to latest commons-parent pom 430753d is described below commit 430753d919c21b11c2786307459b4b170c4e47f8 Author: Carl Hall AuthorDate: Thu Dec 26 22:04:25 2019 -0800 Update to latest commons-parent pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 441be19..6f64400 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.apache.commons commons-parent -48 +50 4.0.0 commons-dbutils
[commons-lang] branch master updated: Don't generate gratuitous garbage.
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-lang.git The following commit(s) were added to refs/heads/master by this push: new 0ef55fe Don't generate gratuitous garbage. 0ef55fe is described below commit 0ef55fe145922d334d645e054fc194207de65b8a Author: Gary Gregory AuthorDate: Thu Dec 26 19:26:14 2019 -0500 Don't generate gratuitous garbage. --- .../java/org/apache/commons/lang3/ArrayUtils.java | 31 ++ .../commons/lang3/exception/ExceptionUtils.java| 2 +- .../apache/commons/lang3/reflect/FieldUtils.java | 17 ++-- .../apache/commons/lang3/reflect/MethodUtils.java | 2 +- .../apache/commons/lang3/reflect/TypeUtils.java| 8 +++--- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index 2aa8510..f719644 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -17,6 +17,9 @@ package org.apache.commons.lang3; import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.Arrays; import java.util.BitSet; import java.util.Comparator; @@ -91,6 +94,20 @@ public class ArrayUtils { public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY = new Double[0]; /** + * An empty immutable {@code Field} array. + * + * @since 3.10 + */ +public static final Field[] EMPTY_FIELD_ARRAY = new Field[0]; + +/** + * An empty immutable {@code Method} array. + * + * @since 3.10 + */ +public static final Method[] EMPTY_METHOD_ARRAY = new Method[0]; + +/** * An empty immutable {@code float} array. */ public static final float[] EMPTY_FLOAT_ARRAY = new float[0]; @@ -141,6 +158,20 @@ public class ArrayUtils { public static final String[] EMPTY_STRING_ARRAY = new String[0]; /** + * An empty immutable {@code Throwable} array. + * + * @since 3.10 + */ +public static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0]; + +/** + * An empty immutable {@code Type} array. + * + * @since 3.10 + */ +public static final Type[] EMPTY_TYPE_ARRAY = new Type[0]; + +/** * The index value when an element is not found in a list or array: {@code -1}. * This value is returned by methods in this class and can also be used in comparisons with values returned by * various method from {@link java.util.List}. diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 6550fd8..152c809 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -438,7 +438,7 @@ public class ExceptionUtils { */ public static Throwable[] getThrowables(final Throwable throwable) { final List list = getThrowableList(throwable); -return list.toArray(new Throwable[0]); +return list.toArray(ArrayUtils.EMPTY_THROWABLE_ARRAY); } /** diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java index 553be4e..07eb839 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java @@ -16,12 +16,6 @@ */ package org.apache.commons.lang3.reflect; -import org.apache.commons.lang3.ClassUtils; -import org.apache.commons.lang3.JavaVersion; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.SystemUtils; -import org.apache.commons.lang3.Validate; - import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -29,6 +23,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.ClassUtils; +import org.apache.commons.lang3.JavaVersion; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemUtils; +import org.apache.commons.lang3.Validate; + /** * Utilities for working with {@link Field}s by reflection. Adapted and refactored from the dormant [reflect] Commons * sandbox component. @@ -199,7 +200,7 @@ public class FieldUtils { */ public static Field[] getAllFields(final Class cls) { final List allFieldsList = getAllFieldsList(cls); -return allFieldsList.toArray(new Field[0]); +return allFieldsList.toArray(ArrayUtils.EMPTY_FIELD_ARRAY); } /** @@ -237,7 +238,7 @@ public class FieldUtils { */
[commons-lang] branch master updated: Use ArrayUtils#EMPTY_STRING_ARRAY instead of creating new empty String arrays.
This is an automated email from the ASF dual-hosted git repository. pascalschumacher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git The following commit(s) were added to refs/heads/master by this push: new d5948be Use ArrayUtils#EMPTY_STRING_ARRAY instead of creating new empty String arrays. d5948be is described below commit d5948be13f788fddbf384643ae6fbac6cca87a18 Author: pascalschumacher AuthorDate: Thu Dec 26 23:51:46 2019 +0100 Use ArrayUtils#EMPTY_STRING_ARRAY instead of creating new empty String arrays. --- src/main/java/org/apache/commons/lang3/StringUtils.java| 10 +- .../org/apache/commons/lang3/exception/ExceptionUtils.java | 4 ++-- src/main/java/org/apache/commons/lang3/text/StrTokenizer.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index d629806..44fba32 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7507,7 +7507,7 @@ public class StringUtils { currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); -return list.toArray(new String[0]); +return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** @@ -7735,7 +7735,7 @@ public class StringUtils { } } -return substrings.toArray(new String[0]); +return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } // --- @@ -7923,7 +7923,7 @@ public class StringUtils { if (match || preserveAllTokens && lastMatch) { list.add(str.substring(start, i)); } -return list.toArray(new String[0]); +return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** @@ -8022,7 +8022,7 @@ public class StringUtils { if (match || preserveAllTokens && lastMatch) { list.add(str.substring(start, i)); } -return list.toArray(new String[0]); +return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** @@ -8835,7 +8835,7 @@ public class StringUtils { if (list.isEmpty()) { return null; } -return list.toArray(new String[0]); +return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index dd154e3..6550fd8 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -274,7 +274,7 @@ public class ExceptionUtils { } frames.addAll(trace); } -return frames.toArray(new String[0]); +return frames.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** @@ -325,7 +325,7 @@ public class ExceptionUtils { while (frames.hasMoreTokens()) { list.add(frames.nextToken()); } -return list.toArray(new String[0]); +return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } /** diff --git a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java index 97fae7d..8a5c33c 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java +++ b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java @@ -604,10 +604,10 @@ public class StrTokenizer implements ListIterator, Cloneable { if (chars == null) { // still call tokenize as subclass may do some work final List split = tokenize(null, 0, 0); -tokens = split.toArray(new String[0]); +tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } else { final List split = tokenize(chars, 0, chars.length); -tokens = split.toArray(new String[0]); +tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY); } } }
[commons-lang] branch master updated: Use Collection#toArray(new T[0]) instead of a presized array as it is faster on modern JVMs.
This is an automated email from the ASF dual-hosted git repository. pascalschumacher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git The following commit(s) were added to refs/heads/master by this push: new 84668a2 Use Collection#toArray(new T[0]) instead of a presized array as it is faster on modern JVMs. 84668a2 is described below commit 84668a2d980316a580030fd64764cb072b520b09 Author: pascalschumacher AuthorDate: Thu Dec 26 22:48:12 2019 +0100 Use Collection#toArray(new T[0]) instead of a presized array as it is faster on modern JVMs. --- src/main/java/org/apache/commons/lang3/CharSet.java| 2 +- src/main/java/org/apache/commons/lang3/StringUtils.java| 10 +- .../org/apache/commons/lang3/exception/ExceptionUtils.java | 6 +++--- src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java | 4 ++-- .../java/org/apache/commons/lang3/reflect/MethodUtils.java | 2 +- src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java | 2 +- src/main/java/org/apache/commons/lang3/text/StrTokenizer.java | 4 ++-- .../org/apache/commons/lang3/time/DurationFormatUtils.java | 2 +- .../java/org/apache/commons/lang3/time/FastDatePrinter.java| 2 +- .../commons/lang3/concurrent/EventCountCircuitBreakerTest.java | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/CharSet.java b/src/main/java/org/apache/commons/lang3/CharSet.java index 3fdfd07..7955115 100644 --- a/src/main/java/org/apache/commons/lang3/CharSet.java +++ b/src/main/java/org/apache/commons/lang3/CharSet.java @@ -225,7 +225,7 @@ public class CharSet implements Serializable { // NOTE: This is no longer public as CharRange is no longer a public class. // It may be replaced when CharSet moves to Range. /*public*/ CharRange[] getCharRanges() { -return set.toArray(new CharRange[set.size()]); +return set.toArray(new CharRange[0]); } //--- diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index abde7ec..d629806 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -7507,7 +7507,7 @@ public class StringUtils { currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); -return list.toArray(new String[list.size()]); +return list.toArray(new String[0]); } /** @@ -7735,7 +7735,7 @@ public class StringUtils { } } -return substrings.toArray(new String[substrings.size()]); +return substrings.toArray(new String[0]); } // --- @@ -7923,7 +7923,7 @@ public class StringUtils { if (match || preserveAllTokens && lastMatch) { list.add(str.substring(start, i)); } -return list.toArray(new String[list.size()]); +return list.toArray(new String[0]); } /** @@ -8022,7 +8022,7 @@ public class StringUtils { if (match || preserveAllTokens && lastMatch) { list.add(str.substring(start, i)); } -return list.toArray(new String[list.size()]); +return list.toArray(new String[0]); } /** @@ -8835,7 +8835,7 @@ public class StringUtils { if (list.isEmpty()) { return null; } -return list.toArray(new String[list.size()]); +return list.toArray(new String[0]); } /** diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 5969614..dd154e3 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -274,7 +274,7 @@ public class ExceptionUtils { } frames.addAll(trace); } -return frames.toArray(new String[frames.size()]); +return frames.toArray(new String[0]); } /** @@ -325,7 +325,7 @@ public class ExceptionUtils { while (frames.hasMoreTokens()) { list.add(frames.nextToken()); } -return list.toArray(new String[list.size()]); +return list.toArray(new String[0]); } /** @@ -438,7 +438,7 @@ public class ExceptionUtils { */ public static Throwable[] getThrowables(final Throwable throwable) { final List list = getThrowableList(throwable); -return list.toArray(new Throwable[list.size()]); +return list.toArray(new Throwable[0]); } /** diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/o
[commons-codec] branch master updated: [CODEC-273] Add Path APIs to org.apache.commons.codec.digest.DigestUtils similar to File APIs.
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 e772d31 [CODEC-273] Add Path APIs to org.apache.commons.codec.digest.DigestUtils similar to File APIs. e772d31 is described below commit e772d31a5d0db091bdb68d12b3c2fe79ba979bda Author: Gary Gregory AuthorDate: Thu Dec 26 09:23:42 2019 -0500 [CODEC-273] Add Path APIs to org.apache.commons.codec.digest.DigestUtils similar to File APIs. --- pom.xml| 1 + src/changes/changes.xml| 1 + .../apache/commons/codec/digest/DigestUtils.java | 75 +- .../commons/codec/digest/DigestUtilsTest.java | 38 --- .../codec/digest/MessageDigestAlgorithmsTest.java | 30 - src/test/resources/empty.bin | 0 6 files changed, 134 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 43a17f5..3cfac9d 100644 --- a/pom.xml +++ b/pom.xml @@ -280,6 +280,7 @@ limitations under the License. src/test/resources/bla.tar.xz +src/test/resources/empty.bin diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7bcef52..d947376 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -52,6 +52,7 @@ The type attribute can be add,update,fix,remove. Add MurmurHash3.hash32x86 methods and IncrementalHash32x86 to fix sign extension error in hash32 methods. Allow repeat calls to MurmurHash3.IncrementalHash32.end() to generate the same value. Add RandomAccessFile digest methods #31. + Add Path APIs to org.apache.commons.codec.digest.DigestUtils similar to File APIs. diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java index da921d3..631306b 100644 --- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java +++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java @@ -20,11 +20,14 @@ package org.apache.commons.codec.digest; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; -import java.io.RandomAccessFile; import java.io.IOException; import java.io.InputStream; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -118,6 +121,24 @@ public class DigestUtils { } /** + * Reads through a File and returns the digest for the data + * + * @param messageDigest + *The MessageDigest to use (e.g. MD5) + * @param data + *Data to digest + * @param options + *options How to open the file + * @return the digest + * @throws IOException + * On error reading from the stream + * @since 1.14 + */ +public static byte[] digest(final MessageDigest messageDigest, final Path data, final OpenOption... options) throws IOException { +return updateDigest(messageDigest, data, options).digest(); +} + +/** * Reads through a RandomAccessFile using non-blocking-io (NIO) and returns the digest for the data * * @param messageDigest The MessageDigest to use (e.g. MD5) @@ -1267,6 +1288,26 @@ public class DigestUtils { return digest; } +/** + * Reads through a Path and updates the digest for the data + * + * @param digest + *The MessageDigest to use (e.g. MD5) + * @param path + *Data to digest + * @param options + *options How to open the file + * @return the digest + * @throws IOException + * On error reading from the stream + * @since 1.14 + */ +public static MessageDigest updateDigest(final MessageDigest digest, final Path path, final OpenOption... options) throws IOException { +try (final BufferedInputStream inputStream = new BufferedInputStream(Files.newInputStream(path, options))) { +return updateDigest(digest, inputStream); +} +} + /** * Reads through a RandomAccessFile and updates the digest for the data using non-blocking-io (NIO) @@ -1398,6 +1439,22 @@ public class DigestUtils { } /** + * Reads through a File and returns the digest for the data + * + * @param data + *Data to digest + * @param options + *options How to open the file + * @return the digest + * @throws IOException + * On error reading from the stream + * @since 1.14 + */
[commons-codec] 02/02: Sort members.
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 commit 6471942097893c67004e4990d77002a9071a7f84 Author: Gary Gregory AuthorDate: Thu Dec 26 09:04:24 2019 -0500 Sort members. --- .../codec/digest/MessageDigestAlgorithmsTest.java | 58 +++--- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java index d0bb626..f1b7295 100644 --- a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java +++ b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java @@ -44,20 +44,6 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class MessageDigestAlgorithmsTest { -@Parameters(name = "{0}") -public static Object[] data() { -return MessageDigestAlgorithms.values(); -} - -private static boolean contains(final String key) { -for(final String s : MessageDigestAlgorithms.values()) { -if (s.equals(key)) { -return true; -} -} -return false; -} - @BeforeClass public static void checkValues() throws Exception { final Field [] fields = MessageDigestAlgorithms.class.getDeclaredFields(); @@ -87,6 +73,20 @@ public class MessageDigestAlgorithmsTest { } } +private static boolean contains(final String key) { +for(final String s : MessageDigestAlgorithms.values()) { +if (s.equals(key)) { +return true; +} +} +return false; +} + +@Parameters(name = "{0}") +public static Object[] data() { +return MessageDigestAlgorithms.values(); +} + private DigestUtilsTest digestUtilsTest; private final String messageDigestAlgorithm; @@ -157,6 +157,21 @@ public class MessageDigestAlgorithmsTest { } @Test +public void testDigestInputStream() throws IOException { +Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); +Assert.assertArrayEquals(digestTestData(), + DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), new ByteArrayInputStream(getTestData(; +Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),new ByteArrayInputStream(getTestData(; +} + +@Test +public void testGetMessageDigest() { +Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); +final MessageDigest messageDigest = DigestUtils.getDigest(messageDigestAlgorithm); +Assert.assertEquals(messageDigestAlgorithm, messageDigest.getAlgorithm()); +} + +@Test public void testNonBlockingDigestRandomAccessFile() throws IOException { Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); @@ -175,19 +190,4 @@ public class MessageDigestAlgorithmsTest { ); } -@Test -public void testDigestInputStream() throws IOException { -Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); -Assert.assertArrayEquals(digestTestData(), - DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), new ByteArrayInputStream(getTestData(; -Assert.assertArrayEquals(digestTestData(), DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),new ByteArrayInputStream(getTestData(; -} - -@Test -public void testGetMessageDigest() { -Assume.assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm)); -final MessageDigest messageDigest = DigestUtils.getDigest(messageDigestAlgorithm); -Assert.assertEquals(messageDigestAlgorithm, messageDigest.getAlgorithm()); -} - }
[commons-codec] branch master updated (ac7a700 -> 6471942)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git. from ac7a700 Prepare for next release. new 251d41c Better param name. new 6471942 Sort members. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/commons/codec/digest/DigestUtils.java | 12 ++--- .../codec/digest/MessageDigestAlgorithmsTest.java | 58 +++--- 2 files changed, 35 insertions(+), 35 deletions(-)
[commons-codec] 01/02: Better param name.
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 commit 251d41c38fe917c9ee371f581ecf9ec651c6384e Author: Gary Gregory AuthorDate: Thu Dec 26 08:53:31 2019 -0500 Better param name. --- .../java/org/apache/commons/codec/digest/DigestUtils.java| 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java index c1a3507..da921d3 100644 --- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java +++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java @@ -1217,8 +1217,8 @@ public class DigestUtils { * @since 1.11 */ public static MessageDigest updateDigest(final MessageDigest digest, final File data) throws IOException { -try (final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(data))) { -return updateDigest(digest, stream); +try (final BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(data))) { +return updateDigest(digest, inputStream); } } @@ -1248,20 +1248,20 @@ public class DigestUtils { * * @param digest *The MessageDigest to use (e.g. MD5) - * @param data + * @param inputStream *Data to digest * @return the digest * @throws IOException * On error reading from the stream * @since 1.8 */ -public static MessageDigest updateDigest(final MessageDigest digest, final InputStream data) throws IOException { +public static MessageDigest updateDigest(final MessageDigest digest, final InputStream inputStream) throws IOException { final byte[] buffer = new byte[STREAM_BUFFER_LENGTH]; -int read = data.read(buffer, 0, STREAM_BUFFER_LENGTH); +int read = inputStream.read(buffer, 0, STREAM_BUFFER_LENGTH); while (read > -1) { digest.update(buffer, 0, read); -read = data.read(buffer, 0, STREAM_BUFFER_LENGTH); +read = inputStream.read(buffer, 0, STREAM_BUFFER_LENGTH); } return digest;
[commons-codec] 01/02: Use final.
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 commit 17d8f331a0dafd731a99254a2dd2b6aba2fc0317 Author: Gary Gregory AuthorDate: Thu Dec 26 08:46:14 2019 -0500 Use final. --- .../java/org/apache/commons/codec/binary/BaseNCodec.java | 4 ++-- .../java/org/apache/commons/codec/digest/MurmurHash3.java| 4 ++-- .../java/org/apache/commons/codec/binary/Base32Test.java | 2 +- .../java/org/apache/commons/codec/binary/Base64Test.java | 4 ++-- .../java/org/apache/commons/codec/binary/BaseNCodecTest.java | 12 ++-- src/test/java/org/apache/commons/codec/binary/HexTest.java | 2 +- .../org/apache/commons/codec/digest/MurmurHash3Test.java | 10 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java index 065f5ef..016a9e8 100644 --- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java +++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java @@ -289,7 +289,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * a value greater than {@code 0} if {@code x > y} as * unsigned values */ -private static int compareUnsigned(int x, int y) { +private static int compareUnsigned(final int x, final int y) { return Integer.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE); } @@ -302,7 +302,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { * @return the capacity * @throws OutOfMemoryError if the {@code minCapacity} is negative */ -private static int createPositiveCapacity(int minCapacity) { +private static int createPositiveCapacity(final int minCapacity) { if (minCapacity < 0) { // overflow throw new OutOfMemoryError("Unable to allocate array size: " + (minCapacity & 0xL)); diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java index 1507b00..65f174d 100644 --- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java +++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java @@ -1104,7 +1104,7 @@ public final class MurmurHash3 { * @param totalLen The total number of input bytes added since the start. * @return The 32-bit hash */ -int finalise(int hash, int unprocessedLength, byte[] unprocessed, int totalLen) { +int finalise(final int hash, final int unprocessedLength, final byte[] unprocessed, final int totalLen) { int result = hash; int k1 = 0; switch (unprocessedLength) { @@ -1169,7 +1169,7 @@ public final class MurmurHash3 { */ @Override @Deprecated -int finalise(int hash, int unprocessedLength, byte[] unprocessed, int totalLen) { +int finalise(final int hash, final int unprocessedLength, final byte[] unprocessed, final int totalLen) { int result = hash; // // Note: This fails to apply masking using 0xff to the 3 remaining bytes. diff --git a/src/test/java/org/apache/commons/codec/binary/Base32Test.java b/src/test/java/org/apache/commons/codec/binary/Base32Test.java index de62be8..360f221 100644 --- a/src/test/java/org/apache/commons/codec/binary/Base32Test.java +++ b/src/test/java/org/apache/commons/codec/binary/Base32Test.java @@ -347,7 +347,7 @@ public class Base32Test { * * @param nbits the number of trailing bits (must be a factor of 5 and {@code <40}) */ -private static void assertBase32DecodingOfTrailingBits(int nbits) { +private static void assertBase32DecodingOfTrailingBits(final int nbits) { final Base32 codec = new Base32(); // Create the encoded bytes. The first characters must be valid so fill with 'zero'. final byte[] encoded = new byte[nbits / 5]; diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Test.java index 3a4af93..d4a63fc 100644 --- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java +++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java @@ -1347,7 +1347,7 @@ public class Base64Test { * * @param nbits the number of trailing bits (must be a factor of 6 and {@code <24}) */ -private static void assertBase64DecodingOfTrailingBits(int nbits) { +private static void assertBase64DecodingOfTrailingBits(final int nbits) { final Base64 codec = new Base64(); // Create the encoded bytes. The first characters must be valid so fill with 'zero'. final byte[] encoded = new byte[nbits / 6]; @@ -1390,7
[commons-codec] 02/02: Prepare for next release.
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 commit ac7a700094c772aed0668273c31477cb8751c2cf Author: Gary Gregory AuthorDate: Thu Dec 26 08:51:20 2019 -0500 Prepare for next release. - Update Apache Commons Parent from 48 to 50. - Update JApiCmp from 0.14.1 to 0.14.3. - Update JaCoCo from 0.8.4 to 0.8.5. - Update release plugin from 1.5 to 1.7. - Update BC version from 1.12 to 1.13. - Reuse parent property commons.pmd.version. --- pom.xml | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index f63db04..43a17f5 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ limitations under the License. org.apache.commons commons-parent -48 +50 commons-codec commons-codec @@ -240,17 +240,17 @@ limitations under the License. UTF-8 ${basedir}/LICENSE-header.txt 2.17 -0.14.1 -0.8.4 +0.14.3 +0.8.5 false false -1.12 +1.13 RC1 -1.5 +1.7 true scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid} Gary Gregory @@ -362,7 +362,7 @@ limitations under the License. org.apache.maven.plugins maven-pmd-plugin -3.12.0 +${commons.pmd.version} ${maven.compiler.target} true
[commons-codec] branch master updated (0ec741f -> ac7a700)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git. from 0ec741f Javadoc. new 17d8f33 Use final. new ac7a700 Prepare for next release. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 12 ++-- .../java/org/apache/commons/codec/binary/BaseNCodec.java | 4 ++-- .../java/org/apache/commons/codec/digest/MurmurHash3.java| 4 ++-- .../java/org/apache/commons/codec/binary/Base32Test.java | 2 +- .../java/org/apache/commons/codec/binary/Base64Test.java | 4 ++-- .../java/org/apache/commons/codec/binary/BaseNCodecTest.java | 12 ++-- src/test/java/org/apache/commons/codec/binary/HexTest.java | 2 +- .../org/apache/commons/codec/digest/MurmurHash3Test.java | 10 +- 8 files changed, 25 insertions(+), 25 deletions(-)
[commons-codec] branch master updated: Javadoc.
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 0ec741f Javadoc. 0ec741f is described below commit 0ec741ff0b60221c47f047d5ca6266d00fc3050c Author: Gary Gregory AuthorDate: Thu Dec 26 08:41:46 2019 -0500 Javadoc. --- .../org/apache/commons/codec/binary/BaseNCodecOutputStream.java | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java index bad975c..b04f6f4 100644 --- a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java +++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java @@ -47,7 +47,13 @@ public class BaseNCodecOutputStream extends FilterOutputStream { private final Context context = new Context(); -// TODO should this be protected? +/** + * TODO should this be protected? + * + * @param out the underlying output or null. + * @param basedCodec a BaseNCodec. + * @param doEncode true to encode, false to decode, TODO should be an enum? + */ public BaseNCodecOutputStream(final OutputStream out, final BaseNCodec basedCodec, final boolean doEncode) { super(out); this.baseNCodec = basedCodec;
[commons-weaver] branch master updated: Use Objects.requireNonNull() instead of custom check. Minor formatting.
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-weaver.git The following commit(s) were added to refs/heads/master by this push: new 61c6e2f Use Objects.requireNonNull() instead of custom check. Minor formatting. 61c6e2f is described below commit 61c6e2f404d1b619c29facf42f914765897a5187 Author: Gary Gregory AuthorDate: Thu Dec 26 08:38:27 2019 -0500 Use Objects.requireNonNull() instead of custom check. Minor formatting. --- .../src/main/java/org/apache/commons/weaver/model/ScanRequest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java b/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java index 1c4cb17..4894174 100644 --- a/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java +++ b/processor/src/main/java/org/apache/commons/weaver/model/ScanRequest.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import org.apache.commons.lang3.Validate; @@ -44,9 +45,7 @@ public class ScanRequest { * @return {@code this}, fluently */ public ScanRequest add(final WeaveInterest interest) { -if (interest == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(interest, "interest"); interests.add(interest); return this; }
[commons-pool] branch master updated: Use Objects.requireNonNull() instead of custom check. Minor formatting.
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-pool.git The following commit(s) were added to refs/heads/master by this push: new 4d4e6db Use Objects.requireNonNull() instead of custom check. Minor formatting. 4d4e6db is described below commit 4d4e6db883331e9b182bf939accd0350573ac9a4 Author: Gary Gregory AuthorDate: Thu Dec 26 08:27:36 2019 -0500 Use Objects.requireNonNull() instead of custom check. Minor formatting. --- .../commons/pool2/impl/LinkedBlockingDeque.java| 33 ++ .../pool2/impl/TestAbandonedObjectPool.java| 5 ++-- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java b/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java index ccd9f65..e024546 100644 --- a/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java +++ b/src/main/java/org/apache/commons/pool2/impl/LinkedBlockingDeque.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Deque; import java.util.Iterator; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; @@ -224,9 +225,7 @@ class LinkedBlockingDeque extends AbstractQueue lock.lock(); // Never contended, but necessary for visibility try { for (final E e : c) { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e); if (!linkLast(e)) { throw new IllegalStateException("Deque full"); } @@ -392,9 +391,7 @@ class LinkedBlockingDeque extends AbstractQueue */ @Override public boolean offerFirst(final E e) { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); lock.lock(); try { return linkFirst(e); @@ -408,9 +405,7 @@ class LinkedBlockingDeque extends AbstractQueue */ @Override public boolean offerLast(final E e) { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); lock.lock(); try { return linkLast(e); @@ -430,9 +425,7 @@ class LinkedBlockingDeque extends AbstractQueue * for space */ public void putFirst(final E e) throws InterruptedException { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); lock.lock(); try { while (!linkFirst(e)) { @@ -454,9 +447,7 @@ class LinkedBlockingDeque extends AbstractQueue * for space */ public void putLast(final E e) throws InterruptedException { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); lock.lock(); try { while (!linkLast(e)) { @@ -483,9 +474,7 @@ class LinkedBlockingDeque extends AbstractQueue */ public boolean offerFirst(final E e, final long timeout, final TimeUnit unit) throws InterruptedException { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); long nanos = unit.toNanos(timeout); lock.lockInterruptibly(); try { @@ -517,9 +506,7 @@ class LinkedBlockingDeque extends AbstractQueue */ public boolean offerLast(final E e, final long timeout, final TimeUnit unit) throws InterruptedException { -if (e == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(e, "e"); long nanos = unit.toNanos(timeout); lock.lockInterruptibly(); try { @@ -940,9 +927,7 @@ class LinkedBlockingDeque extends AbstractQueue * @throws IllegalArgumentException if c is this instance */ public int drainTo(final Collection c, final int maxElements) { -if (c == null) { -throw new NullPointerException(); -} +Objects.requireNonNull(c, "c"); if (c == this) { throw new IllegalArgumentException(); } diff --git a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java index 7579d2e..0c9ebfd 100644 --- a/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java +++ b/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java @@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.lang.management.ManagementFactory; import java.util.ArrayList; +import java.
[commons-lang] branch master updated: CompareToBuilder: Fix checkstyle violation.
This is an automated email from the ASF dual-hosted git repository. pascalschumacher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git The following commit(s) were added to refs/heads/master by this push: new fe44a99 CompareToBuilder: Fix checkstyle violation. fe44a99 is described below commit fe44a99852719ff842ff5ce08b5a37d9b0a0d7fb Author: pascalschumacher AuthorDate: Thu Dec 26 10:25:50 2019 +0100 CompareToBuilder: Fix checkstyle violation. --- src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java index 03ca984..0988629 100644 --- a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java @@ -285,7 +285,7 @@ public class CompareToBuilder implements Builder { } Objects.requireNonNull(lhs, "lhs"); Objects.requireNonNull(rhs, "rhs"); - + Class lhsClazz = lhs.getClass(); if (!lhsClazz.isInstance(rhs)) { throw new ClassCastException();