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 d0e8c210e84677e826f6ad0a3fe30e6c4b9caef7
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Thu Sep 3 08:28:04 2020 -0400

    - Javadoc.
    - Add @SuppressWarnings("resource") for parameter null checks.
    - Better private method name.
    - Format nits.
---
 src/main/java/org/apache/commons/io/IOExceptionList.java    |  4 ++--
 src/main/java/org/apache/commons/io/IOUtils.java            |  4 ++++
 .../java/org/apache/commons/io/input/DemuxInputStream.java  |  4 ++--
 .../java/org/apache/commons/io/input/XmlStreamReader.java   | 13 ++++++-------
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/IOExceptionList.java 
b/src/main/java/org/apache/commons/io/IOExceptionList.java
index 5cb2c74..1d27d88 100644
--- a/src/main/java/org/apache/commons/io/IOExceptionList.java
+++ b/src/main/java/org/apache/commons/io/IOExceptionList.java
@@ -57,7 +57,7 @@ public class IOExceptionList extends IOException {
     }
 
     /**
-     * Gets the cause list.
+     * Gets the cause exception at the given index.
      *
      * @param <T> type of exception to return.
      * @param index index in the cause list.
@@ -68,7 +68,7 @@ public class IOExceptionList extends IOException {
     }
 
     /**
-     * Gets the cause list.
+     * Gets the cause exception at the given index.
      *
      * @param <T> type of exception to return.
      * @param index index in the cause list.
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java 
b/src/main/java/org/apache/commons/io/IOUtils.java
index 55885b8..d5593c6 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -178,6 +178,7 @@ public class IOUtils {
      * @throws NullPointerException if the input parameter is null
      * @since 2.5
      */
+    @SuppressWarnings("resource") // parameter null check
     public static BufferedInputStream buffer(final InputStream inputStream) {
         // reject null early on rather than waiting for IO operation to fail
         // not checked by BufferedInputStream
@@ -196,6 +197,7 @@ public class IOUtils {
      * @throws NullPointerException if the input parameter is null
      * @since 2.5
      */
+    @SuppressWarnings("resource") // parameter null check
     public static BufferedInputStream buffer(final InputStream inputStream, 
final int size) {
         // reject null early on rather than waiting for IO operation to fail
         // not checked by BufferedInputStream
@@ -213,6 +215,7 @@ public class IOUtils {
      * @throws NullPointerException if the input parameter is null
      * @since 2.5
      */
+    @SuppressWarnings("resource") // parameter null check
     public static BufferedOutputStream buffer(final OutputStream outputStream) 
{
         // reject null early on rather than waiting for IO operation to fail
         // not checked by BufferedInputStream
@@ -231,6 +234,7 @@ public class IOUtils {
      * @throws NullPointerException if the input parameter is null
      * @since 2.5
      */
+    @SuppressWarnings("resource") // parameter null check
     public static BufferedOutputStream buffer(final OutputStream outputStream, 
final int size) {
         // reject null early on rather than waiting for IO operation to fail
         // not checked by BufferedInputStream
diff --git a/src/main/java/org/apache/commons/io/input/DemuxInputStream.java 
b/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
index 775478e..f3bf092 100644
--- a/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
@@ -30,7 +30,7 @@ public class DemuxInputStream extends InputStream {
     private final InheritableThreadLocal<InputStream> inputStream = new 
InheritableThreadLocal<>();
 
     /**
-     * Bind the specified stream to the current thread.
+     * Binds the specified stream to the current thread.
      *
      * @param input the stream to bind
      * @return the InputStream that was previously active
@@ -52,7 +52,7 @@ public class DemuxInputStream extends InputStream {
     }
 
     /**
-     * Read byte from stream associated with current thread.
+     * Reads byte from stream associated with current thread.
      *
      * @return the byte read from stream
      * @throws IOException if an error occurs
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 64ce89b..f4144a8 100644
--- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
+++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
@@ -277,7 +277,7 @@ public class XmlStreamReader extends Reader {
         final BOMInputStream bom = new BOMInputStream(new 
BufferedInputStream(inputStream, BUFFER_SIZE), false, BOMS);
         final BOMInputStream pis = new BOMInputStream(bom, true, 
XML_GUESS_BYTES);
         if (conn instanceof HttpURLConnection || contentType != null) {
-            this.encoding = doHttpStream(bom, pis, contentType, lenient);
+            this.encoding = processHttpStream(bom, pis, contentType, lenient);
         } else {
             this.encoding = doRawStream(bom, pis, lenient);
         }
@@ -346,7 +346,7 @@ public class XmlStreamReader extends Reader {
         this.defaultEncoding = defaultEncoding;
         final BOMInputStream bom = new BOMInputStream(new 
BufferedInputStream(inputStream, BUFFER_SIZE), false, BOMS);
         final BOMInputStream pis = new BOMInputStream(bom, true, 
XML_GUESS_BYTES);
-        this.encoding = doHttpStream(bom, pis, httpContentType, lenient);
+        this.encoding = processHttpStream(bom, pis, httpContentType, lenient);
         this.reader = new InputStreamReader(pis, encoding);
     }
 
@@ -456,14 +456,13 @@ public class XmlStreamReader extends Reader {
      * @return the encoding to be used
      * @throws IOException thrown if there is a problem reading the stream.
      */
-    private String doHttpStream(final BOMInputStream bom, final BOMInputStream 
pis, final String httpContentType,
-            final boolean lenient) throws IOException {
-        final String bomEnc      = bom.getBOMCharsetName();
+    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);
         try {
-            return calculateHttpEncoding(httpContentType, bomEnc,
-                    xmlGuessEnc, xmlEnc, lenient);
+            return calculateHttpEncoding(httpContentType, bomEnc, xmlGuessEnc, 
xmlEnc, lenient);
         } catch (final XmlStreamReaderException ex) {
             if (lenient) {
                 return doLenientDetection(httpContentType, ex);

Reply via email to