Nexus: Staging Completed
Message from: https://repository.apache.orgDescription:commons-configuration 2.8-rc2Deployer properties:"userAgent" = "Apache-Maven/3.8.4 (Java 1.8.0_322; Linux 5.17.12-300.fc36.x86_64)""userId" = "mattjuntunen""ip" = "147.92.107.25"Details:The following artifacts have been staged/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-test-sources.jar(SHA1: 02d80881853d579aa745ec46463f05d939b2aa75)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-javadoc.jar.asc(SHA1: 74c3150e16f6e7a454bd362e9101e15d2199a91b)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8.pom.asc(SHA1: 45f7b30baff98d23b6e21bb9292c98566ce47681)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-tests.jar(SHA1: 3345c0138612e3020fb49681c49895653fc92224)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8.jar.asc(SHA1: 3a17ecb641dd770ab506c8a07f6e2883882daef0)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-sources.jar.asc(SHA1: b0ff2f0f62f97ca9797ce7a8227c9f682a2a6720)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-test-sources.jar.asc(SHA1: 853d2409095b20671f3e98739d312df7249d2e04)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-tests.jar.asc(SHA1: 7ff84015b1dbbff46277101a6e259907ff1e6ac8)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-sources.jar(SHA1: fbe9bc19484a2c325a70a1014519ecf47743cf8d)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8-javadoc.jar(SHA1: abb41915b55e221e93c9496c1ecfb8e426cbd1ff)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8.pom(SHA1: 1411a550f9cc30c2e637c1605964c076a9718b3a)/org/apache/commons/commons-configuration2/2.8/commons-configuration2-2.8.jar(SHA1: 9e2ae61c24f1941f2aedb0849ef15e24e27de0d5)Action performed by Matt Juntunen (mattjuntunen)
svn commit: r55251 - in /dev/commons/configuration/2.8-RC2: ./ binaries/ site/ site/apidocs/ site/apidocs/org/ site/apidocs/org/apache/ site/apidocs/org/apache/commons/ site/apidocs/org/apache/commons
Author: mattjuntunen Date: Wed Jun 22 03:29:43 2022 New Revision: 55251 Log: Staging release: commons-configuration2, version: 2.8 [This commit notification would consist of 575 parts, which exceeds the limit of 50 ones, so it was shortened to the summary.]
svn commit: r55250 - /dev/commons/configuration/2.8-RC1/
Author: mattjuntunen Date: Wed Jun 22 03:25:12 2022 New Revision: 55250 Log: Cleaning distribution area for: commons-configuration2 Removed: dev/commons/configuration/2.8-RC1/
[commons-configuration] annotated tag commons-configuration-2.8-RC2 created (now bd8ed955)
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a change to annotated tag commons-configuration-2.8-RC2 in repository https://gitbox.apache.org/repos/asf/commons-configuration.git at bd8ed955 (tag) tagging f540433112b9a93c26c43277c3ec7a3d40565115 (commit) replaces commons-configuration-2.8-RC1 by Matt Juntunen on Tue Jun 21 23:20:26 2022 -0400 - Log - RC2 -BEGIN PGP SIGNATURE- iQHMBAABCAA2FiEEfdU67+3xw9OStR6+NG9Pzs+3CxoFAmKyinoYHG1hdHRqdW50 dW5lbkBhcGFjaGUub3JnAAoJEDRvT87PtwsaDScL/17pW1Gpl75yyNqhmnzuj3jj 859zRkkIECqiPz6DdQ2gZ9vcm0PUFcgmH8UTkbVZw0Xss0zA+gMPbamZMZlsDzfg jPWbfrW9PUlF66nDAaPGJm13gvtYz+L6RTpqweVpMEky+raqNy/VjFPKu+cxwzuX jVcMZ5RJrkK1/65Wse3Juq9knVSA4rMzNH63a3HhyM+m/sbPmEykVoSm9ZeyArVy 69gw0ZGy7enWT6OqnWbNHPDPGEbXpoI4xtCbBlTE69EX9Ss07BSNO8pw8BJcWVhn /9XMfLaVSiI1DNqDqkEv6dz3Z4LCmjFY/SWNypRsONbxLYAZJTkvzKknlwdU+kI3 uLYUVASsfaeNuPDUe/x5mdGxaDzPwh2RYnnWyStgIZyA/N+8cJb8LvESYbcwMOTO zpCNVQKouPRLLiizSu/bc8DMU+U1ogeUK3kje2uz+dSm3xgBgE2PJZzIxlMkQu2x W3DQyzyNG04tQmC3rExqbm8jApRvfPkHmq6itUCSuw== =XjSA -END PGP SIGNATURE- --- No new revisions were added by this update.
[commons-configuration] branch release updated (01e1b407 -> f5404331)
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a change to branch release in repository https://gitbox.apache.org/repos/asf/commons-configuration.git from 01e1b407 updating version add 8493023a simplifying version name from 2.8.0 to 2.8 new e646d337 Merge remote-tracking branch 'origin/master' into release new f5404331 preparing 2.8-rc2 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: README.md | 6 ++-- RELEASE-NOTES.txt | 36 ++ pom.xml| 2 +- src/changes/changes.xml| 2 +- .../configuration2/ImmutableConfiguration.java | 8 ++--- .../PropertiesConfigurationLayout.java | 6 ++-- .../builder/FileBasedBuilderProperties.java| 2 +- .../configuration2/convert/PropertyConverter.java | 4 +-- .../commons/configuration2/io/FileHandler.java | 2 +- .../commons/configuration2/io/FileSystem.java | 2 +- .../configuration2/io/URLConnectionOptions.java| 2 +- .../commons/configuration2/tree/ImmutableNode.java | 2 +- src/site/xdoc/download_configuration.xml | 26 13 files changed, 49 insertions(+), 51 deletions(-)
[commons-configuration] 01/02: Merge remote-tracking branch 'origin/master' into release
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-configuration.git commit e646d337c2e86fbbf17ebf360e46e7c99d77971d Merge: 01e1b407 8493023a Author: Matt Juntunen AuthorDate: Tue Jun 21 22:45:54 2022 -0400 Merge remote-tracking branch 'origin/master' into release src/changes/changes.xml | 2 +- .../org/apache/commons/configuration2/ImmutableConfiguration.java | 8 .../commons/configuration2/PropertiesConfigurationLayout.java | 6 +++--- .../configuration2/builder/FileBasedBuilderProperties.java| 2 +- .../apache/commons/configuration2/convert/PropertyConverter.java | 4 ++-- .../java/org/apache/commons/configuration2/io/FileHandler.java| 2 +- .../java/org/apache/commons/configuration2/io/FileSystem.java | 2 +- .../apache/commons/configuration2/io/URLConnectionOptions.java| 2 +- .../org/apache/commons/configuration2/tree/ImmutableNode.java | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --cc src/changes/changes.xml index 70a00513,822c4b3a..465d5aab --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@@ -21,7 -21,7 +21,7 @@@ Apache Commons Community -
[commons-configuration] 02/02: preparing 2.8-rc2
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch release in repository https://gitbox.apache.org/repos/asf/commons-configuration.git commit f540433112b9a93c26c43277c3ec7a3d40565115 Author: Matt Juntunen AuthorDate: Tue Jun 21 23:18:56 2022 -0400 preparing 2.8-rc2 --- README.md| 6 +++--- RELEASE-NOTES.txt| 36 +++- pom.xml | 2 +- src/site/xdoc/download_configuration.xml | 26 +++ 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b862750c..f10d8bde 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,10 @@ Apache Commons Configuration === -[![Build Status](https://travis-ci.org/apache/commons-configuration.svg)](https://travis-ci.org/apache/commons-configuration) +[![GitHub Actions Status](https://github.com/apache/commons-configuration/workflows/Java%20CI/badge.svg)](https://github.com/apache/commons-configuration/actions) [![Coverage Status](https://codecov.io/gh/apache/commons-configuration/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-configuration) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-configuration2/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-configuration2/) -[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-configuration2/2.7.svg)](https://javadoc.io/doc/org.apache.commons/commons-configuration2/2.7) +[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-configuration2/2.8.svg)](https://javadoc.io/doc/org.apache.commons/commons-configuration2/2.8) Tools to assist in the reading of configuration/preferences files in various formats @@ -68,7 +68,7 @@ Alternatively you can pull it from the central Maven repositories: org.apache.commons commons-configuration2 - 2.7 + 2.8 ``` diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 706f09fe..5291654a 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,5 @@ Apache Commons Configuration -Version 2.8.0 +Version 2.8 Release Notes @@ -25,9 +25,9 @@ o Add PropertiesConfigurationLayout.getBlankLinesBefore() an Thanks to Gary Gregory. o Add PropertiesConfigurationLayout.setBlankLinesBefore() and deprecate setBlancLinesBefore(). Thanks to Gary Gregory. -o Add PropertiesConfigurationLayout.PropertyLayoutData.getBlankLines() and deprecate +o Add PropertiesConfigurationLayout.PropertyLayoutData.getBlankLines() and deprecate getBlancLines(). Thanks to Gary Gregory. -o Add PropertiesConfigurationLayout.PropertyLayoutData.setBlankLines() and deprecate +o Add PropertiesConfigurationLayout.PropertyLayoutData.setBlankLines() and deprecate setBlancLines(). Thanks to Gary Gregory. o CONFIGURATION-789: Add ImmutableConfiguration.getEnum() methods. Thanks to Gary Gregory. o CONFIGURATION-789: Add ImmutableConfiguration.getDuration() methods. Thanks to Gary Gregory. @@ -42,26 +42,26 @@ o CONFIGURATION-802: Use final #111. Thanks to Arturo Bernal. o CONFIGURATION-803: Java 8 lambda improvements and more #112. Thanks to Arturo Bernal. o CONFIGURATION-804: Redundant local variable #113. Thanks to Arturo Bernal. o CONFIGURATION-805: Use try with resource #114. Thanks to Arturo Bernal. -o CONFIGURATION-805: [Javadoc] Specify that typed getList returns null for missing key #100. Thanks to +o CONFIGURATION-805: [Javadoc] Specify that typed getList returns null for missing key #100. Thanks to Roman Zaynetdinov. -o Mention EnvironmentConfiguration in the list of configuration sources #45. Thanks to +o Mention EnvironmentConfiguration in the list of configuration sources #45. Thanks to Oliver B. Fischer. o CONFIGURATION-808: DefaultListDelimiterHandler.escapeList working only for List>String< #137. Thanks to cigaly. o Use final #141. Thanks to Arturo Bernal. o Replace test asserts by simpler but equivalent calls. #139 Thanks to Arturo Bernal. -o CONFIGURATION-764: Single Variable Interpolation #182. Thanks to Ning Zhang, Matt Juntunen, Bruno P. Kinoshita, +o CONFIGURATION-764: Single Variable Interpolation #182. Thanks to Ning Zhang, Matt Juntunen, Bruno P. Kinoshita, Gary Gregory. o Implement proper concurrency in ConstantLookup. Thanks to Gary Gregory. -o CONFIGURATION-813: Support new namespace jakarta.
Nexus: Staging Repository Dropped
Message from: https://repository.apache.orgDescription:cancelling vote on rc1Deployer properties:"userAgent" = "Apache-Maven/3.8.4 (Java 1.8.0_322; Linux 5.17.12-300.fc36.x86_64)""userId" = "mattjuntunen""ip" = "147.92.107.25"Details:The orgapachecommons-1589 staging repository has been dropped.Action performed by Matt Juntunen (mattjuntunen)
[commons-configuration] branch master updated: simplifying version name from 2.8.0 to 2.8
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-configuration.git The following commit(s) were added to refs/heads/master by this push: new 8493023a simplifying version name from 2.8.0 to 2.8 8493023a is described below commit 8493023af135f65252f91748c46f967e743a2f0c Author: Matt Juntunen AuthorDate: Tue Jun 21 22:37:56 2022 -0400 simplifying version name from 2.8.0 to 2.8 --- pom.xml | 4 ++-- src/changes/changes.xml | 2 +- .../org/apache/commons/configuration2/ImmutableConfiguration.java | 8 .../commons/configuration2/PropertiesConfigurationLayout.java | 6 +++--- .../configuration2/builder/FileBasedBuilderProperties.java| 2 +- .../apache/commons/configuration2/convert/PropertyConverter.java | 4 ++-- .../java/org/apache/commons/configuration2/io/FileHandler.java| 2 +- .../java/org/apache/commons/configuration2/io/FileSystem.java | 2 +- .../apache/commons/configuration2/io/URLConnectionOptions.java| 2 +- .../org/apache/commons/configuration2/tree/ImmutableNode.java | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index c5166324..43a33132 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 4.0.0 commons-configuration2 - 2.8.0-SNAPSHOT + 2.8-SNAPSHOT Apache Commons Configuration 2001 @@ -560,7 +560,7 @@ configuration org.apache.commons.configuration2 -2.8.0 +2.8 (reworked 2.x version) commons-configuration-${commons.release.2.version} 1.10 diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2c416023..822c4b3a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -21,7 +21,7 @@ Apache Commons Community - diff --git a/src/main/java/org/apache/commons/configuration2/ImmutableConfiguration.java b/src/main/java/org/apache/commons/configuration2/ImmutableConfiguration.java index a3171197..2f388163 100644 --- a/src/main/java/org/apache/commons/configuration2/ImmutableConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/ImmutableConfiguration.java @@ -318,7 +318,7 @@ public interface ImmutableConfiguration { * @return The associated Duration if key is found and has valid format, default value otherwise. * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that is not a * Duration. - * @since 2.8.0 + * @since 2.8 */ default Duration getDuration(final String key) { final String string = getString(key); @@ -336,7 +336,7 @@ public interface ImmutableConfiguration { * @return The associated Duration if key is found and has valid format, default value otherwise. * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that is not a * Duration. - * @since 2.8.0 + * @since 2.8 */ default Duration getDuration(final String key, final Duration defaultValue) { final Object value = getProperty(key); @@ -378,7 +378,7 @@ public interface ImmutableConfiguration { * * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that is not a * String. - * @since 2.8.0 + * @since 2.8 */ default > T getEnum(final String key, final Class enumType) { try { @@ -400,7 +400,7 @@ public interface ImmutableConfiguration { * * @throws org.apache.commons.configuration2.ex.ConversionException is thrown if the key maps to an object that is not a * Enum. - * @since 2.8.0 + * @since 2.8 */ default > T getEnum(final String key, final Class enumType, final T defaultValue) { final String strValue = getString(key, null); diff --git a/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java b/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java index b0f3fe62..6cf2f033 100644 --- a/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java +++ b/src/main/java/org/apache/commons/configuration2/PropertiesConfigurationLayout.java @@ -228,7 +228,7 @@ public class PropertiesConfigurationLayout implements EventListener { * @param url the {@code URL} location * @param urlConnectionOptions options * @return a reference to this object for method chaining - * @since 2.8.0 + * @since 2.8 */ default T setURL(final URL url, final URLConnectionOptions urlConnectionOptions) { return setURL(url); diff --git a/src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java b/src/main/ja
[commons-crypto] 01/01: Merge branch 'master' into sebb-docker
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch sebb-docker in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit e48d56b541173c4e3a3a26a539b6d6c76d1c0cec Merge: d77e054 a9b15a3 Author: Sebb AuthorDate: Tue Jun 21 23:56:13 2022 +0100 Merge branch 'master' into sebb-docker checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-crypto] branch sebb-docker updated (d77e054 -> e48d56b)
This is an automated email from the ASF dual-hosted git repository. sebb pushed a change to branch sebb-docker in repository https://gitbox.apache.org/repos/asf/commons-crypto.git from d77e054 Document build process add a9b15a3 Allow for Checkstyle syntax change new e48d56b Merge branch 'master' into sebb-docker The 1 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: checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-crypto] branch master updated: Allow for Checkstyle syntax change
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new a9b15a3 Allow for Checkstyle syntax change a9b15a3 is described below commit a9b15a3d1b9effd5220ea92ba4f3709e32caeb04 Author: Sebb AuthorDate: Tue Jun 21 23:55:42 2022 +0100 Allow for Checkstyle syntax change --- checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle.xml b/checkstyle.xml index 3f22f3d..41f710f 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -36,7 +36,7 @@ limitations under the License. - +
[commons-crypto] branch sebb-docker updated: Document build process
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch sebb-docker in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/sebb-docker by this push: new d77e054 Document build process d77e054 is described below commit d77e05420234a5452ed901924a1c169b8113cc70 Author: Sebb AuthorDate: Tue Jun 21 23:12:45 2022 +0100 Document build process --- src/docker/README.md | 33 ++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/docker/README.md b/src/docker/README.md index be38962..176fb97 100644 --- a/src/docker/README.md +++ b/src/docker/README.md @@ -31,14 +31,14 @@ target/classes/org/apache/commons/crypto/native before creating the release. For example, the macOS object can be added as target/classes/org/apache/commons/crypto/native/Mac/x86_64/libcommons-crypto.jnilib -# Building with Docker +# Building the Docker image ``` cd src/docker docker compose build crypto ``` -# Running with Docker +# Running the Docker image ``` cd src/docker @@ -47,4 +47,31 @@ target/classes/org/apache/commons/crypto/native/Mac/x86_64/libcommons-crypto.jni docker compose run --entrypoint src/docker/build.sh crypto # run full build docker compose run --entrypoint src/docker/build_linux32.sh crypto # optionally run linux32 build # N.B. the linux32 build needs an additional install, but that causes linux 64 bit builds to fail. -``` \ No newline at end of file +``` + +# Creating a release candidate using macOS + +This is the easiest if the release manager has access to a macOS host. + +The steps are: + +- mvn clean +- cd src/docker +- docker compose run --entrypoint src/docker/build.sh crypto +- docker compose run --entrypoint src/docker/build_linux32.sh crypto # optional +- cd ../.. + +Now perform the release (don't run mvn clean!) +- mvn release ... + +# Creating a release candidate using another OS + +If the Release Manager (RM) does not have access to a macOS system, they will need to obtain a copy +of the macOS native binary from another Commons developer. + +The process starts as above, but just before using the host system to build the release, +add the macOS binary to the workspace at: + +```target/classes/org/apache/commons/crypto/native/Mac/x86_64/libcommons-crypto.jnilib``` + +The release can then be created in the normal way.
[commons-io] branch master updated: Reuse StandardCharsets
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-io.git The following commit(s) were added to refs/heads/master by this push: new 2ce0a112 Reuse StandardCharsets 2ce0a112 is described below commit 2ce0a112df85f88e2891384076ef74ae1021b506 Author: Gary Gregory AuthorDate: Tue Jun 21 16:45:42 2022 -0400 Reuse StandardCharsets --- src/main/java/org/apache/commons/io/FileUtils.java | 2 +- src/main/java/org/apache/commons/io/IOUtils.java | 2 +- .../java/org/apache/commons/io/LineIterator.java | 4 ++- .../commons/io/output/WriterOutputStream.java | 3 +- .../java/org/apache/commons/io/CopyUtilsTest.java | 4 +-- .../java/org/apache/commons/io/FileUtilsTest.java | 10 --- .../java/org/apache/commons/io/IOUtilsTest.java| 12 .../org/apache/commons/io/IOUtilsWriteTest.java| 4 +-- .../org/apache/commons/io/LineIteratorTest.java| 19 +++- .../io/input/CharSequenceInputStreamTest.java | 34 -- .../commons/io/input/QueueInputStreamTest.java | 3 +- .../commons/io/input/ReaderInputStreamTest.java| 15 ++ .../ReversedLinesFileReaderTestParamBlockSize.java | 13 + .../ReversedLinesFileReaderTestParamFile.java | 31 +++- .../input/ReversedLinesFileReaderTestSimple.java | 3 +- .../org/apache/commons/io/input/TailerTest.java| 2 +- .../commons/io/input/XmlStreamReaderTest.java | 12 .../io/input/compatibility/XmlStreamReader.java| 12 .../io/output/FileWriterWithEncodingTest.java | 5 ++-- .../commons/io/output/LockableFileWriterTest.java | 2 +- .../commons/io/output/WriterOutputStreamTest.java | 26 ++--- .../commons/io/output/XmlStreamWriterTest.java | 20 ++--- 22 files changed, 135 insertions(+), 103 deletions(-) diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 29dd79bc..5c85238e 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -2134,7 +2134,7 @@ public class FileUtils { * The recommended usage pattern is: * * - * LineIterator it = FileUtils.lineIterator(file, "UTF-8"); + * LineIterator it = FileUtils.lineIterator(file, StandardCharsets.UTF_8.name()); * try { * while (it.hasNext()) { * String line = it.nextLine(); diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index b923b44b..c161d51a 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -1726,7 +1726,7 @@ public class IOUtils { * * * try { - * LineIterator it = IOUtils.lineIterator(stream, "UTF-8"); + * LineIterator it = IOUtils.lineIterator(stream, StandardCharsets.UTF_8.name()); * while (it.hasNext()) { * String line = it.nextLine(); * /// do something with line diff --git a/src/main/java/org/apache/commons/io/LineIterator.java b/src/main/java/org/apache/commons/io/LineIterator.java index b1b05d5c..e1d750d5 100644 --- a/src/main/java/org/apache/commons/io/LineIterator.java +++ b/src/main/java/org/apache/commons/io/LineIterator.java @@ -35,7 +35,7 @@ import java.util.Objects; * * The recommended usage pattern is: * - * LineIterator it = FileUtils.lineIterator(file, "UTF-8"); + * LineIterator it = FileUtils.lineIterator(file, StandardCharsets.UTF_8.name()); * try { * while (it.hasNext()) { * String line = it.nextLine(); @@ -64,8 +64,10 @@ public class LineIterator implements Iterator, Closeable { public static void closeQuietly(final LineIterator iterator) { IOUtils.closeQuietly(iterator); } + /** The reader that is being read. */ private final BufferedReader bufferedReader; + /** The current line. */ private String cachedLine; diff --git a/src/main/java/org/apache/commons/io/output/WriterOutputStream.java b/src/main/java/org/apache/commons/io/output/WriterOutputStream.java index e44647c5..c9ab9cb3 100644 --- a/src/main/java/org/apache/commons/io/output/WriterOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/WriterOutputStream.java @@ -25,6 +25,7 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.Charsets; import org.apache.commons.io.charset.CharsetDecoders; @@ -83,7 +84,7 @@ public class WriterOutputStream extends OutputStream { * @param charset the charset to check the support for */ private static void checkIbmJdkWithBrokenUTF16(final Charset charset){ -if (!"UTF-16".
[commons-crypto] branch sebb-docker updated (7937428 -> aea82ec)
This is an automated email from the ASF dual-hosted git repository. sebb pushed a change to branch sebb-docker in repository https://gitbox.apache.org/repos/asf/commons-crypto.git from 7937428 Add missing win and linux builds from pom profiles add 7922e7a Fix warning add 4a22092 Correct capitalisation new aea82ec Merge branch 'master' into sebb-docker The 1 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: src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-crypto] 01/01: Merge branch 'master' into sebb-docker
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch sebb-docker in repository https://gitbox.apache.org/repos/asf/commons-crypto.git commit aea82ec9df50326bedbe233905aa75800d66afa9 Merge: 7937428 4a22092 Author: Sebb AuthorDate: Tue Jun 21 21:42:17 2022 +0100 Merge branch 'master' into sebb-docker src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[commons-crypto] branch master updated: Correct capitalisation
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git The following commit(s) were added to refs/heads/master by this push: new 4a22092 Correct capitalisation 4a22092 is described below commit 4a22092656379308ad45213e6d9f87e7bd8fcd4d Author: Sebb AuthorDate: Tue Jun 21 21:39:27 2022 +0100 Correct capitalisation --- src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index 1a60f2c..7b1dd23 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -27,7 +27,7 @@ https://commons.apache.org/proper/commons-crypto/download_crypto.cgi"/> - +
[commons-io] branch master updated: Add Add XmlStreamWriter(OutputStream, Charset)
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-io.git The following commit(s) were added to refs/heads/master by this push: new 9a257182 Add Add XmlStreamWriter(OutputStream, Charset) 9a257182 is described below commit 9a2571827af7fc47565a716fada2807d20d4524d Author: Gary Gregory AuthorDate: Tue Jun 21 14:00:11 2022 -0400 Add Add XmlStreamWriter(OutputStream, Charset) --- src/changes/changes.xml| 3 ++ .../apache/commons/io/output/XmlStreamWriter.java | 58 ++ .../commons/io/output/XmlStreamWriterTest.java | 37 -- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f0675cd9..ae41dec8 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -397,6 +397,9 @@ The type attribute can be add,update,fix,remove. Add Charsets.toCharset(Charset, Charset). Add Charsets.toCharset(String, Charset). + +Add XmlStreamWriter(OutputStream, Charset). + Bump actions/cache from 2.1.6 to 3.0.4 #307, #337. diff --git a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java index 4b3ba09e..37233fff 100644 --- a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java +++ b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java @@ -24,9 +24,13 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Locale; +import java.util.Objects; import java.util.regex.Matcher; +import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.XmlStreamReader; @@ -43,13 +47,13 @@ public class XmlStreamWriter extends Writer { private final OutputStream out; -private final String defaultEncoding; +private final Charset defaultCharset; -private StringWriter xmlPrologWriter = new StringWriter(BUFFER_SIZE); +private StringWriter prologWriter = new StringWriter(BUFFER_SIZE); private Writer writer; -private String encoding; +private Charset charset; /** * Constructs a new XML stream writer for the specified file @@ -84,7 +88,7 @@ public class XmlStreamWriter extends Writer { * @param out The output stream */ public XmlStreamWriter(final OutputStream out) { -this(out, null); +this(out, StandardCharsets.UTF_8); } /** @@ -95,8 +99,20 @@ public class XmlStreamWriter extends Writer { * @param defaultEncoding The default encoding if not encoding could be detected */ public XmlStreamWriter(final OutputStream out, final String defaultEncoding) { +this(out, Charsets.toCharset(defaultEncoding, StandardCharsets.UTF_8)); +} + +/** + * Constructs a new XML stream writer for the specified output stream + * with the specified default encoding. + * + * @param out The output stream + * @param defaultEncoding The default encoding if not encoding could be detected + * @since 2.12.0 + */ +public XmlStreamWriter(final OutputStream out, final Charset defaultEncoding) { this.out = out; -this.defaultEncoding = defaultEncoding != null ? defaultEncoding : "UTF-8"; +this.defaultCharset = Objects.requireNonNull(defaultEncoding); } /** @@ -107,9 +123,9 @@ public class XmlStreamWriter extends Writer { @Override public void close() throws IOException { if (writer == null) { -encoding = defaultEncoding; -writer = new OutputStreamWriter(out, encoding); -writer.write(xmlPrologWriter.toString()); +charset = defaultCharset; +writer = new OutputStreamWriter(out, charset); +writer.write(prologWriter.toString()); } writer.close(); } @@ -125,11 +141,11 @@ public class XmlStreamWriter extends Writer { private void detectEncoding(final char[] cbuf, final int off, final int len) throws IOException { int size = len; -final StringBuffer xmlProlog = xmlPrologWriter.getBuffer(); +final StringBuffer xmlProlog = prologWriter.getBuffer(); if (xmlProlog.length() + len > BUFFER_SIZE) { size = BUFFER_SIZE - xmlProlog.length(); } -xmlPrologWriter.write(cbuf, off, size); +prologWriter.write(cbuf, off, size); // try to determine encoding if (xmlProlog.length() >= 5) { @@ -141,26 +157,26 @@ public class XmlStreamWriter extends Writer { final Matcher m = XmlStreamReader.ENCODING_PATTERN.matcher(xmlProlog.subst
[commons-io] branch master updated: Reuse StandardCharsets
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-io.git The following commit(s) were added to refs/heads/master by this push: new a2e012d5 Reuse StandardCharsets a2e012d5 is described below commit a2e012d5486becae451ca837273ffebe45d910b3 Author: Gary Gregory AuthorDate: Tue Jun 21 13:51:48 2022 -0400 Reuse StandardCharsets --- src/main/java/org/apache/commons/io/ByteOrderMark.java | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/io/ByteOrderMark.java b/src/main/java/org/apache/commons/io/ByteOrderMark.java index 18a3b045..3d5494ea 100644 --- a/src/main/java/org/apache/commons/io/ByteOrderMark.java +++ b/src/main/java/org/apache/commons/io/ByteOrderMark.java @@ -17,6 +17,7 @@ package org.apache.commons.io; import java.io.Serializable; +import java.nio.charset.StandardCharsets; import java.util.Locale; import java.util.Objects; @@ -34,13 +35,13 @@ public class ByteOrderMark implements Serializable { private static final long serialVersionUID = 1L; /** UTF-8 BOM. */ -public static final ByteOrderMark UTF_8= new ByteOrderMark("UTF-8", 0xEF, 0xBB, 0xBF); +public static final ByteOrderMark UTF_8 = new ByteOrderMark(StandardCharsets.UTF_8.name(), 0xEF, 0xBB, 0xBF); /** UTF-16BE BOM (Big-Endian). */ -public static final ByteOrderMark UTF_16BE = new ByteOrderMark("UTF-16BE", 0xFE, 0xFF); +public static final ByteOrderMark UTF_16BE = new ByteOrderMark(StandardCharsets.UTF_16BE.name(), 0xFE, 0xFF); /** UTF-16LE BOM (Little-Endian). */ -public static final ByteOrderMark UTF_16LE = new ByteOrderMark("UTF-16LE", 0xFF, 0xFE); +public static final ByteOrderMark UTF_16LE = new ByteOrderMark(StandardCharsets.UTF_16LE.name(), 0xFF, 0xFE); /** * UTF-32BE BOM (Big-Endian).
[commons-io] branch master updated: Add Charsets.toCharset(Charset, Charset).
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-io.git The following commit(s) were added to refs/heads/master by this push: new 12b97b14 Add Charsets.toCharset(Charset, Charset). 12b97b14 is described below commit 12b97b145355b381863b6fd7a7f0ab9614f74ab0 Author: Gary Gregory AuthorDate: Tue Jun 21 13:51:28 2022 -0400 Add Charsets.toCharset(Charset, Charset). Add Charsets.toCharset(String, Charset). --- src/changes/changes.xml| 4 src/main/java/org/apache/commons/io/Charsets.java | 27 +- .../java/org/apache/commons/io/CharsetsTest.java | 14 +-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 63ba6968..f0675cd9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -393,6 +393,10 @@ The type attribute can be add,update,fix,remove. Add IOUtils.closeQuietly(Iterable). Add IOUtils.closeQuietly(Stream ). + +Add Charsets.toCharset(Charset, Charset). +Add Charsets.toCharset(String, Charset). + Bump actions/cache from 2.1.6 to 3.0.4 #307, #337. diff --git a/src/main/java/org/apache/commons/io/Charsets.java b/src/main/java/org/apache/commons/io/Charsets.java index d2ba98e5..37275b8c 100644 --- a/src/main/java/org/apache/commons/io/Charsets.java +++ b/src/main/java/org/apache/commons/io/Charsets.java @@ -183,6 +183,18 @@ public class Charsets { return charset == null ? Charset.defaultCharset() : charset; } +/** + * Returns the given charset if non-null, otherwise return defaultCharset. + * + * @param charset The charset to test, may be null. + * @param defaultCharset The charset to return if charset is null, may be null. + * @return a Charset . + * @since 2.12.0 + */ +public static Charset toCharset(final Charset charset, final Charset defaultCharset) { +return charset == null ? defaultCharset : charset; +} + /** * Returns a Charset for the named charset. If the name is null, return the default Charset. * @@ -191,6 +203,19 @@ public class Charsets { * @throws UnsupportedCharsetException If the named charset is unavailable (unchecked exception). */ public static Charset toCharset(final String charsetName) throws UnsupportedCharsetException { -return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName); +return toCharset(charsetName, Charset.defaultCharset()); +} + +/** + * Returns a Charset for the named charset. If the name is null, return the given default Charset. + * + * @param charsetName The name of the requested charset, may be null. + * @param defaultCharset The name charset to return if charsetName is null, may be null. + * @return a Charset for the named charset. + * @throws UnsupportedCharsetException If the named charset is unavailable (unchecked exception). + * @since 2.12.0 + */ +public static Charset toCharset(final String charsetName, final Charset defaultCharset) throws UnsupportedCharsetException { +return charsetName == null ? defaultCharset : Charset.forName(charsetName); } } diff --git a/src/test/java/org/apache/commons/io/CharsetsTest.java b/src/test/java/org/apache/commons/io/CharsetsTest.java index 39cb329f..b68b90b6 100644 --- a/src/test/java/org/apache/commons/io/CharsetsTest.java +++ b/src/test/java/org/apache/commons/io/CharsetsTest.java @@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test; /** * Tests {@link Charsets}. - * */ @SuppressWarnings("deprecation") // testing deprecated code public class CharsetsTest { @@ -51,13 +50,24 @@ public class CharsetsTest { } @Test -public void testToCharset() { +public void testToCharset_String() { assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null)); assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null)); assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset())); assertEquals(StandardCharsets.UTF_8, Charsets.toCharset(StandardCharsets.UTF_8)); } +@Test +public void testToCharset_String_Charset() { +assertEquals(null, Charsets.toCharset((String) null, null)); +assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null, Charset.defaultCharset())); +assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null, Charset.defaultCharset())); +assertEquals(null, Charsets.toCharset((Charset) null, null)); +assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset(), Charset.defaultCharset())); +assertEquals(StandardC
[commons-io] 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-io.git The following commit(s) were added to refs/heads/master by this push: new 94f0f788 Javadoc 94f0f788 is described below commit 94f0f7880b9ea9b3e5221db4f34b139bf544b907 Author: Gary Gregory AuthorDate: Tue Jun 21 13:49:16 2022 -0400 Javadoc --- src/main/java/org/apache/commons/io/IOUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 7ac55595..b923b44b 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -475,6 +475,8 @@ public class IOUtils { /** * Avoids the need to type cast. + * + * @param closeable the object to close, may be null */ private static void closeQ(final Closeable closeable) { closeQuietly(closeable, null);
[commons-io] branch master updated: Add IOUtils.closeQuietly(Collection).
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-io.git The following commit(s) were added to refs/heads/master by this push: new 84886836 Add IOUtils.closeQuietly(Collection). 84886836 is described below commit 84886836fd37de2b7cd291ba7b5e7c88a4654b17 Author: Gary Gregory AuthorDate: Tue Jun 21 13:41:00 2022 -0400 Add IOUtils.closeQuietly(Collection). Add IOUtils.closeQuietly(Stream). Internal refactoring to avoid type casts. --- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2b1a69bf..63ba6968 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -390,7 +390,7 @@ The type attribute can be add,update,fix,remove. Add IOBiConsumer.noop(). -Add IOUtils.closeQuietly(Collection). +Add IOUtils.closeQuietly(Iterable ). Add IOUtils.closeQuietly(Stream ).
[commons-io] 02/02: Add IOUtils.closeQuietly(Collection).
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-io.git commit 57313b3ed3b356d9a81103f4dbcc1eb38b9f2c0b Author: Gary Gregory AuthorDate: Tue Jun 21 13:40:37 2022 -0400 Add IOUtils.closeQuietly(Collection). Add IOUtils.closeQuietly(Stream). Internal refactoring to avoid type casts. --- src/changes/changes.xml| 6 ++- src/main/java/org/apache/commons/io/IOUtils.java | 61 ++ .../java/org/apache/commons/io/IOUtilsTest.java| 16 +++--- .../serialization/AbstractCloseableListTest.java | 10 +--- 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index fd142081..2b1a69bf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -334,7 +334,7 @@ The type attribute can be add,update,fix,remove. - PathUtils.getAclFileAttributeView(Path, LinkOption...) - PathUtils.getDosFileAttributeView(Path, LinkOption...) - PathUtils.getPosixFileAttributeView(Path, LinkOption...) - + Make commons-io a JPMS module by adding module-info.class. @@ -389,6 +389,10 @@ The type attribute can be add,update,fix,remove. Add IOBiConsumer.noop(). + +Add IOUtils.closeQuietly(Collection). +Add IOUtils.closeQuietly(Stream ). + Bump actions/cache from 2.1.6 to 3.0.4 #307, #337. diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 1e1b2a95..7ac55595 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -51,6 +51,7 @@ import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.function.Consumer; +import java.util.stream.Stream; import org.apache.commons.io.function.IOConsumer; import org.apache.commons.io.input.QueueInputStream; @@ -472,6 +473,13 @@ public class IOUtils { closeQuietly(closeable, null); } +/** + * Avoids the need to type cast. + */ +private static void closeQ(final Closeable closeable) { +closeQuietly(closeable, null); +} + /** * Closes a {@link Closeable} unconditionally. * @@ -520,7 +528,7 @@ public class IOUtils { */ public static void closeQuietly(final Closeable... closeables) { if (closeables != null) { -Arrays.stream(closeables).forEach(IOUtils::closeQuietly); +closeQuietly(Arrays.stream(closeables)); } } @@ -573,7 +581,39 @@ public class IOUtils { * @see Throwable#addSuppressed(java.lang.Throwable) */ public static void closeQuietly(final InputStream input) { -closeQuietly((Closeable) input); +closeQ(input); +} + +/** + * Closes an iterable of {@link Closeable} unconditionally. + * + * Equivalent calling {@link Closeable#close()} on each element, except any exceptions will be ignored. + * + * + * @param closeables the objects to close, may be null or already closed + * @see #closeQuietly(Closeable) + * @since 2.12.0 + */ +public static void closeQuietly(final Iterable closeables) { +if (closeables != null) { +closeables.forEach(IOUtils::closeQuietly); +} +} + +/** + * Closes a stream of {@link Closeable} unconditionally. + * + * Equivalent calling {@link Closeable#close()} on each element, except any exceptions will be ignored. + * + * + * @param closeables the objects to close, may be null or already closed + * @see #closeQuietly(Closeable) + * @since 2.12.0 + */ +public static void closeQuietly(final Stream closeables) { +if (closeables != null) { +closeables.forEach(IOUtils::closeQuietly); +} } /** @@ -607,7 +647,7 @@ public class IOUtils { * @see Throwable#addSuppressed(java.lang.Throwable) */ public static void closeQuietly(final OutputStream output) { -closeQuietly((Closeable) output); +closeQ(output); } /** @@ -640,7 +680,7 @@ public class IOUtils { * @see Throwable#addSuppressed(java.lang.Throwable) */ public static void closeQuietly(final Reader reader) { -closeQuietly((Closeable) reader); +closeQ(reader); } /** @@ -673,7 +713,7 @@ public class IOUtils { * @see Throwable#addSuppressed(java.lang.Throwable) */ public static void closeQuietly(final Selector selector) { -closeQuietly((Closeable) selector); +closeQ(selector); } /** @@ -706,7 +746,7 @@ public class IOUtils { * @see Throwable#addSuppressed(java.lang.Throwable) */ public sta
[commons-io] 01/02: Refactor magic strings
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-io.git commit 3620e8e42d205efd1440a3f54928a1963d151673 Author: Gary Gregory AuthorDate: Tue Jun 21 12:25:56 2022 -0400 Refactor magic strings --- .../commons/io/input/XmlStreamReaderTest.java | 254 +++-- 1 file changed, 132 insertions(+), 122 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java index 6556cb75..6e6e6839 100644 --- a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java @@ -41,6 +41,16 @@ import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.DefaultLocale; public class XmlStreamReaderTest { + +private static final String ISO_8859_1 = "ISO-8859-1"; +private static final String US_ASCII = "US-ASCII"; +private static final String UTF_16 = "UTF-16"; +private static final String UTF_16LE = "UTF-16LE"; +private static final String UTF_16BE = "UTF-16BE"; +private static final String UTF_32 = "UTF-32"; +private static final String UTF_32LE = "UTF-32LE"; +private static final String UTF_32BE = "UTF-32BE"; +private static final String UTF_8 = "UTF-8"; private static final String XML5 = "xml-prolog-encoding-spaced-single-quotes"; private static final String XML4 = "xml-prolog-encoding-single-quotes"; private static final String XML3 = "xml-prolog-encoding-double-quotes"; @@ -153,7 +163,7 @@ public class XmlStreamReaderTest { throws Exception { try (InputStream is = getXmlInputStream(bomEnc, prologEnc == null ? XML1 : XML3, streamEnc, prologEnc); XmlStreamReader xmlReader = new XmlStreamReader(is, cT, false, alternateEnc)) { -if (!streamEnc.equals("UTF-16")) { +if (!streamEnc.equals(UTF_16)) { // we can not assert things here because UTF-8, US-ASCII and // ISO-8859-1 look alike for the chars used for detection // (niallp 2010-10-06 - I re-instated the check below - the tests(6) passed) @@ -170,7 +180,7 @@ public class XmlStreamReaderTest { public void testEncodingAttributeXML() throws Exception { try (InputStream is = new ByteArrayInputStream(ENCODING_ATTRIBUTE_XML.getBytes(StandardCharsets.UTF_8)); XmlStreamReader xmlReader = new XmlStreamReader(is, "", true)) { -assertEquals(xmlReader.getEncoding(), "UTF-8"); +assertEquals(xmlReader.getEncoding(), UTF_8); } } @@ -180,93 +190,93 @@ public class XmlStreamReaderTest { // checks for non-UTF-16 encodings (18 tests) and these failed // _testHttpValid("application/xml", "no-bom", "US-ASCII", null); // _testHttpValid("application/xml", "UTF-8-bom", "US-ASCII", null); -testHttpValid("application/xml", "UTF-8-bom", "UTF-8", null); -testHttpValid("application/xml", "UTF-8-bom", "UTF-8", "UTF-8"); -testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null); -testHttpValid("application/xml;charset=\"UTF-8\"", "UTF-8-bom", "UTF-8", null); -testHttpValid("application/xml;charset='UTF-8'", "UTF-8-bom", "UTF-8", null); -testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8"); -testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null); -testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); -testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); - -testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null); -testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); -testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); - -testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", null); -testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32"); -testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE"); - -testHttpInvalid("application/xml", "UTF-8-bom", "US-ASCII", "US-ASCII"); -testHttpInvalid("application/xml;charset=UTF-16", "UTF-16LE", "UTF-8", "UTF-8"); -testHttpInvalid("application/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE"); -testHttpInvalid("application/xml;charset=UTF-32", "UTF-32LE", "UTF-8", "UTF-8"); -testHttpInvalid("application/xml;charset=UTF-32", "no-bom", "UTF-32BE", "UTF-32BE"); - -testHttpValid("text/xml", "no-bom", "US-ASCII", null); -testHttpValid("text/xml;charset=UTF-8", "UTF-8-bo
[commons-io] branch master updated (fdfdf5c7 -> 57313b3e)
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-io.git from fdfdf5c7 Use try-with-resources new 3620e8e4 Refactor magic strings new 57313b3e Add IOUtils.closeQuietly(Collection). 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: src/changes/changes.xml| 6 +- src/main/java/org/apache/commons/io/IOUtils.java | 61 - .../java/org/apache/commons/io/IOUtilsTest.java| 16 +- .../commons/io/input/XmlStreamReaderTest.java | 254 +++-- .../serialization/AbstractCloseableListTest.java | 10 +- 5 files changed, 199 insertions(+), 148 deletions(-)
[commons-io] 05/05: Use try-with-resources
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-io.git commit fdfdf5c7249bb6dbbec0091e29574f3b067cb6e0 Author: Gary Gregory AuthorDate: Tue Jun 21 12:18:36 2022 -0400 Use try-with-resources --- .../commons/io/input/NullInputStreamTest.java | 68 +-- .../apache/commons/io/input/NullReaderTest.java| 95 +++ .../commons/io/input/TaggedInputStreamTest.java| 47 --- .../io/input/UnixLineEndingInputStreamTest.java| 11 +- .../UnsynchronizedByteArrayInputStreamTest.java| 20 ++- .../commons/io/input/XmlStreamReaderTest.java | 135 ++--- .../io/input/XmlStreamReaderUtilitiesTest.java | 18 ++- 7 files changed, 188 insertions(+), 206 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java index 2fcaa030..49f31a1c 100644 --- a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java @@ -71,51 +71,47 @@ public class NullInputStreamTest { public void testMarkAndReset() throws Exception { int position = 0; final int readlimit = 10; -@SuppressWarnings("resource") // this is actually closed -final InputStream input = new TestNullInputStream(100, true, false); +try (InputStream input = new TestNullInputStream(100, true, false)) { -assertTrue(input.markSupported(), "Mark Should be Supported"); +assertTrue(input.markSupported(), "Mark Should be Supported"); -// No Mark -try { -input.reset(); -fail("Read limit exceeded, expected IOException "); -} catch (final IOException e) { -assertEquals("No position has been marked", e.getMessage(), "No Mark IOException message"); -} +// No Mark +try { +input.reset(); +fail("Read limit exceeded, expected IOException "); +} catch (final IOException e) { +assertEquals("No position has been marked", e.getMessage(), "No Mark IOException message"); +} -for (; position < 3; position++) { -assertEquals(position, input.read(), "Read Before Mark [" + position +"]"); -} +for (; position < 3; position++) { +assertEquals(position, input.read(), "Read Before Mark [" + position + "]"); +} -// Mark -input.mark(readlimit); +// Mark +input.mark(readlimit); -// Read further -for (int i = 0; i < 3; i++) { -assertEquals(position + i, input.read(), "Read After Mark [" + i +"]"); -} +// Read further +for (int i = 0; i < 3; i++) { +assertEquals(position + i, input.read(), "Read After Mark [" + i + "]"); +} -// Reset -input.reset(); +// Reset +input.reset(); -// Read From marked position -for (int i = 0; i < readlimit + 1; i++) { -assertEquals(position + i, input.read(), "Read After Reset [" + i +"]"); -} +// Read From marked position +for (int i = 0; i < readlimit + 1; i++) { +assertEquals(position + i, input.read(), "Read After Reset [" + i + "]"); +} -// Reset after read limit passed -try { -input.reset(); -fail("Read limit exceeded, expected IOException "); -} catch (final IOException e) { -assertEquals("Marked position [" + position - + "] is no longer valid - passed the read limit [" - + readlimit + "]", - e.getMessage(), - "Read limit IOException message"); +// Reset after read limit passed +try { +input.reset(); +fail("Read limit exceeded, expected IOException "); +} catch (final IOException e) { +assertEquals("Marked position [" + position + "] is no longer valid - passed the read limit [" + readlimit + "]", e.getMessage(), +"Read limit IOException message"); +} } -input.close(); } @Test diff --git a/src/test/java/org/apache/commons/io/input/NullReaderTest.java b/src/test/java/org/apache/commons/io/input/NullReaderTest.java index 87cd2542..39d8673e 100644 --- a/src/test/java/org/apache/commons/io/input/NullReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/NullReaderTest.java @@ -71,51 +71,47 @@ public class NullReaderTest { public void testMarkAndReset() throws Exception { int position = 0; final int readlimit =
[commons-io] 01/05: Use Files API instead of custom fixture building code.
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-io.git commit 1adda8117345fd8baaf998c268e253f3eacb0ad7 Author: Gary Gregory AuthorDate: Tue Jun 21 09:44:13 2022 -0400 Use Files API instead of custom fixture building code. --- src/test/java/org/apache/commons/io/FileUtilsTest.java | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java index cd39eac3..4de76b6e 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTest.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java @@ -2454,26 +2454,20 @@ public class FileUtilsTest extends AbstractTempDirTest { assertEquals(31, data[2]); } - @Test public void testReadFileToStringWithDefaultEncoding() throws Exception { final File file = new File(tempDirFile, "read.obj"); -final OutputStream out = Files.newOutputStream(file.toPath()); -final byte[] text = "Hello /u1234".getBytes(); -out.write(text); -out.close(); +final String fixture = "Hello /u1234"; +Files.write(file.toPath(), fixture.getBytes()); -final String data = FileUtils.readFileToString(file); -assertEquals("Hello /u1234", data); +assertEquals(fixture, FileUtils.readFileToString(file)); } @Test public void testReadFileToStringWithEncoding() throws Exception { final File file = new File(tempDirFile, "read.obj"); -final OutputStream out = Files.newOutputStream(file.toPath()); final byte[] text = "Hello /u1234".getBytes(StandardCharsets.UTF_8); -out.write(text); -out.close(); +Files.write(file.toPath(), text); final String data = FileUtils.readFileToString(file, "UTF8"); assertEquals("Hello /u1234", data);
[commons-io] 02/05: Use try-with-resources
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-io.git commit 7a6d0d59c67cb0e8ebdff8bdd7d7b77eb423653b Author: Gary Gregory AuthorDate: Tue Jun 21 09:46:47 2022 -0400 Use try-with-resources --- src/test/java/org/apache/commons/io/IOCaseTest.java | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/apache/commons/io/IOCaseTest.java b/src/test/java/org/apache/commons/io/IOCaseTest.java index aa77db94..a73aa2fa 100644 --- a/src/test/java/org/apache/commons/io/IOCaseTest.java +++ b/src/test/java/org/apache/commons/io/IOCaseTest.java @@ -31,8 +31,7 @@ import java.io.ObjectOutputStream; import org.junit.jupiter.api.Test; /** - * This is used to test IOCase for correctness. - * + * Tests {@link IOCase}. */ public class IOCaseTest { @@ -40,10 +39,10 @@ public class IOCaseTest { private IOCase serialize(final IOCase value) throws Exception { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); -final ObjectOutputStream out = new ObjectOutputStream(buf); -out.writeObject(value); -out.flush(); -out.close(); +try (final ObjectOutputStream out = new ObjectOutputStream(buf)) { +out.writeObject(value); +out.flush(); +} final ByteArrayInputStream bufin = new ByteArrayInputStream(buf.toByteArray()); final ObjectInputStream in = new ObjectInputStream(bufin);
[commons-io] 03/05: Use IOUtils
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-io.git commit 4b52a6f541e9e95714fb499232169e0faccfb642 Author: Gary Gregory AuthorDate: Tue Jun 21 09:53:10 2022 -0400 Use IOUtils --- .../java/org/apache/commons/io/input/AbstractInputStreamTest.java | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java index d6ac78d7..8be2d503 100644 --- a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -54,10 +55,7 @@ public abstract class AbstractInputStreamTest { @AfterEach public void tearDown() throws IOException { inputFile.delete(); - -for (final InputStream is : inputStreams) { -is.close(); -} +IOUtils.close(inputStreams); } @Test
[commons-io] branch master updated (4a3f5edc -> fdfdf5c7)
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-io.git from 4a3f5edc Use Files API instead of custom fixture building code. new 1adda811 Use Files API instead of custom fixture building code. new 7a6d0d59 Use try-with-resources new 4b52a6f5 Use IOUtils new 5a33c5cc Use SerializationUtils to build test fixtures new fdfdf5c7 Use try-with-resources The 5 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: .../java/org/apache/commons/io/FileUtilsTest.java | 14 +-- .../java/org/apache/commons/io/IOCaseTest.java | 11 +- .../commons/io/input/AbstractInputStreamTest.java | 6 +- .../io/input/ClassLoaderObjectInputStreamTest.java | 118 +- .../commons/io/input/NullInputStreamTest.java | 68 +-- .../apache/commons/io/input/NullReaderTest.java| 95 +++ .../commons/io/input/TaggedInputStreamTest.java| 47 --- .../io/input/UnixLineEndingInputStreamTest.java| 11 +- .../UnsynchronizedByteArrayInputStreamTest.java| 20 ++- .../commons/io/input/XmlStreamReaderTest.java | 135 ++--- .../io/input/XmlStreamReaderUtilitiesTest.java | 18 ++- 11 files changed, 232 insertions(+), 311 deletions(-)
[commons-io] 04/05: Use SerializationUtils to build test fixtures
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-io.git commit 5a33c5ccd8e1861edd5efe3962d8a5e860fd6af8 Author: Gary Gregory AuthorDate: Tue Jun 21 09:59:41 2022 -0400 Use SerializationUtils to build test fixtures --- .../io/input/ClassLoaderObjectInputStreamTest.java | 118 ++--- 1 file changed, 33 insertions(+), 85 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java index a57ccbfc..be77df4d 100644 --- a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java @@ -27,19 +27,21 @@ import java.io.InputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import org.apache.commons.lang3.SerializationUtils; + /** - * Tests the CountingInputStream. - * + * Tests {@link ClassLoaderObjectInputStream}. */ public class ClassLoaderObjectInputStreamTest { -/* Note: This test case tests the simplest functionality of - * ObjectInputStream. IF we really wanted to test ClassLoaderObjectInputStream - * we would probably need to create a transient Class Loader. -TO +/* + * Note: This test case tests the simplest functionality of ObjectInputStream. IF we really wanted to test + * ClassLoaderObjectInputStream we would probably need to create a transient Class Loader. -TO */ - -private enum E {A, B, C} +private enum E { +A, B, C +} private static class Test implements Serializable { private static final long serialVersionUID = 1L; @@ -66,9 +68,7 @@ public class ClassLoaderObjectInputStreamTest { public boolean equals(final Object other) { if (other instanceof Test) { final Test tother = (Test) other; -return this.i == tother.i -& this.e == tother.e -& equalObject(tother.o); +return this.i == tother.i & this.e == tother.e & equalObject(tother.o); } return false; } @@ -81,108 +81,63 @@ public class ClassLoaderObjectInputStreamTest { @org.junit.jupiter.api.Test public void testExpected() throws Exception { - -final ByteArrayOutputStream baos = new ByteArrayOutputStream(); -final ObjectOutputStream oos = new ObjectOutputStream(baos); - -final Object input = Boolean.FALSE; -oos.writeObject(input); - -final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); -try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(), -bais)) { +final Boolean input = Boolean.FALSE; +final InputStream bais = new ByteArrayInputStream(SerializationUtils.serialize(input)); +try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais)) { final Object result = clois.readObject(); - assertEquals(input, result); } } @org.junit.jupiter.api.Test public void testLong() throws Exception { - -final ByteArrayOutputStream baos = new ByteArrayOutputStream(); -final ObjectOutputStream oos = new ObjectOutputStream(baos); - -final Object input = (long) 123; -oos.writeObject(input); - -final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); -try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(), -bais)) { +final Long input = 123L; +final InputStream bais = new ByteArrayInputStream(SerializationUtils.serialize(input)); +try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais)) { final Object result = clois.readObject(); - assertEquals(input, result); } } @org.junit.jupiter.api.Test public void testObject1() throws Exception { - -final ByteArrayOutputStream baos = new ByteArrayOutputStream(); -final ObjectOutputStream oos = new ObjectOutputStream(baos); - -final Object input = new Test(123, null); -oos.writeObject(input); -oos.close(); - -final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); -try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(), -bais)) { +final Test input = new Test(123, null); +final InputStream bais = new ByteArrayInputStream(SerializationUtils.serialize(input)); +try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream
[commons-io] branch master updated: Use Files API instead of custom fixture building code.
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-io.git The following commit(s) were added to refs/heads/master by this push: new 4a3f5edc Use Files API instead of custom fixture building code. 4a3f5edc is described below commit 4a3f5edca499f145459562dfda5723ab13a979d1 Author: Gary Gregory AuthorDate: Tue Jun 21 09:38:07 2022 -0400 Use Files API instead of custom fixture building code. --- src/test/java/org/apache/commons/io/FileUtilsTest.java | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java index eea1dde8..cd39eac3 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTest.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java @@ -2445,11 +2445,7 @@ public class FileUtilsTest extends AbstractTempDirTest { @Test public void testReadFileToByteArray() throws Exception { final File file = new File(tempDirFile, "read.txt"); -final OutputStream out = Files.newOutputStream(file.toPath()); -out.write(11); -out.write(21); -out.write(31); -out.close(); +Files.write(file.toPath(), new byte[] {11, 21, 31}); final byte[] data = FileUtils.readFileToByteArray(file); assertEquals(3, data.length);
[commons-io] 05/05: Use Objects.requireNonNull()
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-io.git commit fffa8406955ca838a53e5092a6300df4d579baa9 Author: Gary Gregory AuthorDate: Tue Jun 21 09:30:12 2022 -0400 Use Objects.requireNonNull() Javadoc. Reuse own API. --- .../java/org/apache/commons/io/LineIterator.java | 5 ++-- .../io/output/DeferredFileOutputStream.java| 19 ++--- .../org/apache/commons/io/LineIteratorTest.java| 31 +- .../io/output/DeferredFileOutputStreamTest.java| 2 +- 4 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/apache/commons/io/LineIterator.java b/src/main/java/org/apache/commons/io/LineIterator.java index 67fe5728..b1b05d5c 100644 --- a/src/main/java/org/apache/commons/io/LineIterator.java +++ b/src/main/java/org/apache/commons/io/LineIterator.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.Reader; import java.util.Iterator; import java.util.NoSuchElementException; +import java.util.Objects; /** * An Iterator over the lines in a {@link Reader}. @@ -78,9 +79,7 @@ public class LineIterator implements Iterator, Closeable { * @throws IllegalArgumentException if the reader is null */ public LineIterator(final Reader reader) throws IllegalArgumentException { -if (reader == null) { -throw new IllegalArgumentException("Reader must not be null"); -} +Objects.requireNonNull(reader, "reader"); if (reader instanceof BufferedReader) { bufferedReader = (BufferedReader) reader; } else { diff --git a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java index 143587a4..4e419fab 100644 --- a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import java.util.function.Supplier; import org.apache.commons.io.file.PathUtils; @@ -140,9 +141,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream { public DeferredFileOutputStream(final int threshold, final int initialBufferSize, final String prefix, final String suffix, final File directory) { this(threshold, null, prefix, suffix, directory, initialBufferSize); -if (prefix == null) { -throw new IllegalArgumentException("Temporary file prefix is missing"); -} +Objects.requireNonNull("prefix", prefix); if (initialBufferSize < 0) { throw new IllegalArgumentException("Initial buffer size must be atleast 0."); } @@ -163,9 +162,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream { public DeferredFileOutputStream(final int threshold, final String prefix, final String suffix, final File directory) { this(threshold, null, prefix, suffix, directory, AbstractByteArrayOutputStream.DEFAULT_SIZE); -if (prefix == null) { -throw new IllegalArgumentException("Temporary file prefix is missing"); -} +Objects.requireNonNull(prefix, "prefix"); } /** @@ -180,7 +177,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream { } /** - * Returns the data for this output stream as an array of bytes, assuming that the data has been retained in memory. + * Gets the data for this output stream as an array of bytes, assuming that the data has been retained in memory. * If the data was written to disk, this method returns {@code null}. * * @return The data for this output stream, or {@code null} if no such data is available. @@ -190,7 +187,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream { } /** - * Returns either the output file specified in the constructor or the temporary file created or null. + * Gets either the output file specified in the constructor or the temporary file created or null. * * If the constructor specifying the file is used then it returns that same output file, even when threshold has not * been reached. @@ -205,7 +202,7 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream { } /** - * Returns the current output stream. This may be memory based or disk based, depending on the current state with + * Gets the current output stream. This may be memory based or disk based, depending on the current state with * respect to the threshold. * * @return The underlying output stream. @@ -218,7 +215,7 @@ public class DeferredFileOutputStream
[commons-io] 01/05: Format tweak
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-io.git commit 92a67fccf7396845b27801cd07480cfed30589b9 Author: Gary Gregory AuthorDate: Tue Jun 21 07:55:42 2022 -0400 Format tweak --- src/main/java/org/apache/commons/io/input/XmlStreamReader.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java index d1e39f49..7d666758 100644 --- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java +++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java @@ -789,9 +789,8 @@ public class XmlStreamReader extends Reader { * @return the encoding to be used * @throws IOException thrown if there is a problem reading the stream. */ -private String doRawStream(final BOMInputStream bom, final BOMInputStream pis, final boolean lenient) -throws IOException { -final String bomEnc = bom.getBOMCharsetName(); +private String doRawStream(final BOMInputStream bom, final BOMInputStream pis, final boolean lenient) throws IOException { +final String bomEnc = bom.getBOMCharsetName(); final String xmlGuessEnc = pis.getBOMCharsetName(); final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); try {
[commons-io] 04/05: Fix exception message typo
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-io.git commit eda19377969aa38a88a5ea989ad7170172578f82 Author: Gary Gregory AuthorDate: Tue Jun 21 08:12:01 2022 -0400 Fix exception message typo --- src/main/java/org/apache/commons/io/input/BOMInputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/io/input/BOMInputStream.java b/src/main/java/org/apache/commons/io/input/BOMInputStream.java index ec7f8207..5df9c943 100644 --- a/src/main/java/org/apache/commons/io/input/BOMInputStream.java +++ b/src/main/java/org/apache/commons/io/input/BOMInputStream.java @@ -246,7 +246,7 @@ public class BOMInputStream extends ProxyInputStream { */ public boolean hasBOM(final ByteOrderMark bom) throws IOException { if (!boms.contains(bom)) { -throw new IllegalArgumentException("Stream not configure to detect " + bom); +throw new IllegalArgumentException("Stream not configured to detect " + bom); } getBOM(); return byteOrderMark != null && byteOrderMark.equals(bom);
[commons-io] 02/05: Whitespace and name tweaks
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-io.git commit 99106fd1670193815411b931556bdc39f86ba9bd Author: Gary Gregory AuthorDate: Tue Jun 21 08:03:20 2022 -0400 Whitespace and name tweaks --- .../apache/commons/io/input/XmlStreamReader.java | 33 ++ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java index 7d666758..0dec7002 100644 --- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java +++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java @@ -98,7 +98,7 @@ public class XmlStreamReader extends Reader { ByteOrderMark.UTF_32LE }; -// UTF_16LE and UTF_32LE have the same two starting BOM bytes. +/** UTF_16LE and UTF_32LE have the same two starting BOM bytes. */ private static final ByteOrderMark[] XML_GUESS_BYTES = { new ByteOrderMark(UTF_8,0x3C, 0x3F, 0x78, 0x6D), new ByteOrderMark(UTF_16BE, 0x00, 0x3C, 0x00, 0x3F), @@ -453,7 +453,6 @@ public class XmlStreamReader extends Reader { this(inputStream, httpContentType, lenient, null); } - /** * Constructs a Reader using an InputStream and the associated content-type * header. This constructor is lenient regarding the encoding detection. @@ -547,7 +546,6 @@ public class XmlStreamReader extends Reader { * the URL. */ public XmlStreamReader(final URL url) throws IOException { -// TODO URLConnection leak. this(Objects.requireNonNull(url, "url").openConnection(), null); } @@ -580,14 +578,14 @@ public class XmlStreamReader extends Reader { final String contentType = urlConnection.getContentType(); final InputStream inputStream = urlConnection.getInputStream(); @SuppressWarnings("resource") // managed by the InputStreamReader tracked by this instance -final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS); -final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES); +final BOMInputStream bomInput = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS); +final BOMInputStream piInput = new BOMInputStream(bomInput, true, XML_GUESS_BYTES); if (urlConnection instanceof HttpURLConnection || contentType != null) { -this.encoding = processHttpStream(bom, pis, contentType, lenient); +this.encoding = processHttpStream(bomInput, piInput, contentType, lenient); } else { -this.encoding = doRawStream(bom, pis, lenient); +this.encoding = doRawStream(bomInput, piInput, lenient); } -this.reader = new InputStreamReader(pis, encoding); +this.reader = new InputStreamReader(piInput, encoding); } /** @@ -826,21 +824,20 @@ public class XmlStreamReader extends Reader { } /** - * Processes a HTTP stream. + * Processes an HTTP stream. * - * @param bom BOMInputStream to detect byte order marks - * @param pis BOMInputStream to guess XML encoding + * @param bomInput BOMInputStream to detect byte order marks + * @param piInput BOMInputStream to guess XML encoding * @param httpContentType The HTTP content type - * @param lenient indicates if the charset encoding detection should be - *relaxed. + * @param lenient indicates if the charset encoding detection should be relaxed. * @return the encoding to be used * @throws IOException thrown if there is a problem reading the stream. */ -private String processHttpStream(final BOMInputStream bom, final BOMInputStream pis, final String httpContentType, -final boolean lenient) throws IOException { -final String bomEnc = bom.getBOMCharsetName(); -final String xmlGuessEnc = pis.getBOMCharsetName(); -final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); +private String processHttpStream(final BOMInputStream bomInput, final BOMInputStream piInput, final String httpContentType, final boolean lenient) +throws IOException { +final String bomEnc = bomInput.getBOMCharsetName(); +final String xmlGuessEnc = piInput.getBOMCharsetName(); +final String xmlEnc = getXmlProlog(piInput, xmlGuessEnc); try { return calculateHttpEncoding(httpContentType, bomEnc, xmlGuessEnc, xmlEnc, lenient); } catch (final XmlStreamReaderException ex) {
[commons-io] 03/05: Reuse StandardCharsets
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-io.git commit e2d4476418ec53037fbbf0c36ff35f5185ed1895 Author: Gary Gregory AuthorDate: Tue Jun 21 08:11:42 2022 -0400 Reuse StandardCharsets Javadoc --- .../java/org/apache/commons/io/input/XmlStreamReader.java | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java index 0dec7002..2efeb39b 100644 --- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java +++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java @@ -27,6 +27,7 @@ import java.io.StringReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.text.MessageFormat; @@ -72,19 +73,19 @@ import org.apache.commons.io.IOUtils; */ public class XmlStreamReader extends Reader { -private static final String UTF_8 = "UTF-8"; +private static final String UTF_8 = StandardCharsets.UTF_8.name(); -private static final String US_ASCII = "US-ASCII"; +private static final String US_ASCII = StandardCharsets.US_ASCII.name(); -private static final String UTF_16BE = "UTF-16BE"; +private static final String UTF_16BE = StandardCharsets.UTF_16BE.name(); -private static final String UTF_16LE = "UTF-16LE"; +private static final String UTF_16LE = StandardCharsets.UTF_16LE.name(); private static final String UTF_32BE = "UTF-32BE"; private static final String UTF_32LE = "UTF-32LE"; -private static final String UTF_16 = "UTF-16"; +private static final String UTF_16 = StandardCharsets.UTF_16.name(); private static final String UTF_32 = "UTF-32"; @@ -446,7 +447,7 @@ public class XmlStreamReader extends Reader { *relaxed. * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not - * be determined according to the specs. + * be determined according to the specification. */ public XmlStreamReader(final InputStream inputStream, final String httpContentType, final boolean lenient) throws IOException { @@ -492,7 +493,7 @@ public class XmlStreamReader extends Reader { * @param defaultEncoding The default encoding * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not - * be determined according to the specs. + * be determined according to the specification. */ @SuppressWarnings("resource") // InputStream is managed through a InputStreamReader in this instance. public XmlStreamReader(final InputStream inputStream, final String httpContentType,
[commons-io] branch master updated (950fc0a4 -> fffa8406)
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-io.git from 950fc0a4 Inline single constant reference to other constant new 92a67fcc Format tweak new 99106fd1 Whitespace and name tweaks new e2d44764 Reuse StandardCharsets new eda19377 Fix exception message typo new fffa8406 Use Objects.requireNonNull() The 5 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: .../java/org/apache/commons/io/LineIterator.java | 5 +- .../apache/commons/io/input/BOMInputStream.java| 2 +- .../apache/commons/io/input/XmlStreamReader.java | 53 ++ .../io/output/DeferredFileOutputStream.java| 19 .../org/apache/commons/io/LineIteratorTest.java| 31 +++-- .../io/output/DeferredFileOutputStreamTest.java| 2 +- 6 files changed, 43 insertions(+), 69 deletions(-)
[commons-io] branch master updated: Inline single constant reference to other constant
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-io.git The following commit(s) were added to refs/heads/master by this push: new 950fc0a4 Inline single constant reference to other constant 950fc0a4 is described below commit 950fc0a47428d64dfb01c62099af30ea30de6cb9 Author: Gary Gregory AuthorDate: Tue Jun 21 07:50:22 2022 -0400 Inline single constant reference to other constant --- src/main/java/org/apache/commons/io/output/XmlStreamWriter.java | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java index 0dcdd871..4b3ba09e 100644 --- a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java +++ b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java @@ -26,7 +26,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Locale; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.XmlStreamReader; @@ -39,9 +38,8 @@ import org.apache.commons.io.input.XmlStreamReader; * @since 2.0 */ public class XmlStreamWriter extends Writer { -private static final int BUFFER_SIZE = IOUtils.DEFAULT_BUFFER_SIZE; -static final Pattern ENCODING_PATTERN = XmlStreamReader.ENCODING_PATTERN; +private static final int BUFFER_SIZE = IOUtils.DEFAULT_BUFFER_SIZE; private final OutputStream out; @@ -140,7 +138,7 @@ public class XmlStreamWriter extends Writer { final int xmlPrologEnd = xmlProlog.indexOf("?>"); if (xmlPrologEnd > 0) { // ok, full XML prolog written: let's extract encoding -final Matcher m = ENCODING_PATTERN.matcher(xmlProlog.substring(0, +final Matcher m = XmlStreamReader.ENCODING_PATTERN.matcher(xmlProlog.substring(0, xmlPrologEnd)); if (m.find()) { encoding = m.group(1).toUpperCase(Locale.ROOT);
[commons-io] 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-io.git The following commit(s) were added to refs/heads/master by this push: new 42574b3b Javadoc 42574b3b is described below commit 42574b3b442e42d898ea8304f42e66b24e0559f8 Author: Gary Gregory AuthorDate: Tue Jun 21 07:47:51 2022 -0400 Javadoc --- .../apache/commons/io/input/XmlStreamReader.java | 91 -- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java index 5a490bfe..d1e39f49 100644 --- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java +++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java @@ -71,6 +71,7 @@ import org.apache.commons.io.IOUtils; * @since 2.0 */ public class XmlStreamReader extends Reader { + private static final String UTF_8 = "UTF-8"; private static final String US_ASCII = "US-ASCII"; @@ -135,7 +136,7 @@ public class XmlStreamReader extends Reader { "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME"; /** - * Returns charset parameter value, NULL if not present, NULL if + * Gets the charset parameter value, NULL if not present, NULL if * httpContentType is NULL. * * @param httpContentType the HTTP content type @@ -156,7 +157,7 @@ public class XmlStreamReader extends Reader { } /** - * Returns MIME type or NULL if httpContentType is NULL. + * Gets the MIME type or NULL if httpContentType is NULL. * * @param httpContentType the HTTP content type * @return The mime content type @@ -176,7 +177,7 @@ public class XmlStreamReader extends Reader { } /** - * Returns the encoding declared in the , NULL if none. + * Gets the encoding declared in the , NULL if none. * * @param inputStream InputStream to create the reader from. * @param guessedEnc guessed encoding @@ -230,7 +231,7 @@ public class XmlStreamReader extends Reader { } /** - * Indicates if the MIME type belongs to the APPLICATION XML family. + * Tests if the MIME type belongs to the APPLICATION XML family. * * @param mime The mime type * @return true if the mime type belongs to the APPLICATION XML family, @@ -241,11 +242,11 @@ public class XmlStreamReader extends Reader { (mime.equals("application/xml") || mime.equals("application/xml-dtd") || mime.equals("application/xml-external-parsed-entity") || - mime.startsWith("application/") && mime.endsWith("+xml")); +mime.startsWith("application/") && mime.endsWith("+xml")); } /** - * Indicates if the MIME type belongs to the TEXT XML family. + * Tests if the MIME type belongs to the TEXT XML family. * * @param mime The mime type * @return true if the mime type belongs to the TEXT XML family, @@ -255,7 +256,7 @@ public class XmlStreamReader extends Reader { return mime != null && (mime.equals("text/xml") || mime.equals("text/xml-external-parsed-entity") || - mime.startsWith("text/") && mime.endsWith("+xml")); + mime.startsWith("text/") && mime.endsWith("+xml")); } private final Reader reader; @@ -265,13 +266,15 @@ public class XmlStreamReader extends Reader { private final String defaultEncoding; /** - * Creates a Reader for a File. + * Constructs a Reader for a File. * * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, * if this is also missing defaults to UTF-8. + * * * It does a lenient charset encoding detection, check the constructor with * the lenient parameter for details. + * * * @param file File to create a Reader from. * @throws IOException thrown if there is a problem reading the file. @@ -281,12 +284,14 @@ public class XmlStreamReader extends Reader { } /** - * Creates a Reader for a raw InputStream. + * Constructs a Reader for a raw InputStream. * * It follows the same logic used for files. + * * * It does a lenient charset encoding detection, check the constructor with * the lenient parameter for details. + * * * @param inputStream InputStream to create a Reader from. * @throws IOException thrown if there is a problem reading the stream. @@ -296,24 +301,31 @@ public class XmlStreamReader extends Reader { } /** - * Creates a Reader for a raw InputStream. + * Constructs a Reader for a raw InputStream. * * It follows the same logic used for files. + * * * If le
[commons-io] 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-io.git The following commit(s) were added to refs/heads/master by this push: new f2ee0df4 Javadoc f2ee0df4 is described below commit f2ee0df41f31bebc2694e55954e8dfd2e9787603 Author: Gary Gregory AuthorDate: Tue Jun 21 07:40:54 2022 -0400 Javadoc --- .../input/MessageDigestCalculatingInputStream.java | 42 +++--- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java index 324f4381..5f3d54dd 100644 --- a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java +++ b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java @@ -24,16 +24,26 @@ import java.security.Provider; /** - * This class is an example for using an {@link ObservableInputStream}. It - * creates its own {@link org.apache.commons.io.input.ObservableInputStream.Observer}, - * which calculates a checksum using a MessageDigest, for example an MD5 sum. - * Note: Neither {@link ObservableInputStream}, nor {@link MessageDigest}, - * are thread safe. So is {@link MessageDigestCalculatingInputStream}. + * This class is an example for using an {@link ObservableInputStream}. It creates its own + * {@link org.apache.commons.io.input.ObservableInputStream.Observer}, which calculates a checksum using a + * MessageDigest, for example an MD5 sum. + * + * See the MessageDigest section in the + * https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest";> Java + * Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names. + * + * + * Note: Neither {@link ObservableInputStream}, nor {@link MessageDigest}, are thread safe. So is + * {@link MessageDigestCalculatingInputStream}. + * */ public class MessageDigestCalculatingInputStream extends ObservableInputStream { /** * The default message digest algorithm. + * + * The MD5 cryptographic algorithm is weak and should not be used. + * */ private static final String DEFAULT_ALGORITHM = "MD5"; @@ -68,7 +78,7 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { * Creates a new instance, which calculates a signature on the given stream, using a {@link MessageDigest} with the * "MD5" algorithm. * - * The MD5 algorithm is weak and should not be used. + * The MD5 algorithm is weak and should not be used. * * * @param inputStream the stream to calculate the message digest for @@ -79,7 +89,8 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { this(inputStream, getDefaultMessageDigest()); } -/** Creates a new instance, which calculates a signature on the given stream, +/** + * Creates a new instance, which calculates a signature on the given stream, * using the given {@link MessageDigest}. * @param inputStream the stream to calculate the message digest for * @param messageDigest the message digest to use @@ -94,7 +105,10 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { * given algorithm. * * @param inputStream the stream to calculate the message digest for - * @param algorithm the name of the algorithm to use + * @param algorithm the name of the algorithm requested. See the MessageDigest section in the + *https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest";> + *Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard + *algorithm names. * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified * algorithm. */ @@ -104,24 +118,26 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream { } /** - * Gets a MessageDigest object that implements the a digest algorithm. - * - * @return a Message Digest object that implements the specified algorithm. + * Gets a MessageDigest object that implements the default digest algorithm. * + * @return a Message Digest object that implements the default algorithm. * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation. - * * @see Provider */ static MessageDigest getDefaultMessageDigest() throws NoSuchAlgorithmException { return MessageDigest.getInstance(DEFAULT_ALGORITHM); } -/** Returns the {@link MessageDigest}, which is being used for generating