You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/07/01 21:15:14 UTC

(commons-io) branch master updated (d8a0c4fc3 -> 11e8800e5)

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 d8a0c4fc3 [IO-874] FileUtils.forceDelete can delete a broken symlink again #756
     new 99aad6d3d Reduce vertical whitespace
     new 11e8800e5 Internal refactoring

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/conf/spotbugs-exclude-filter.xml                   |  9 ---------
 .../org/apache/commons/io/input/BOMInputStream.java    | 18 +++++++++---------
 2 files changed, 9 insertions(+), 18 deletions(-)


(commons-io) 02/02: Internal refactoring

Posted by gg...@apache.org.
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 11e8800e5d14921e93f1600d5d2a5c9457c0f77d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 1 17:15:09 2025 -0400

    Internal refactoring
    
    No need to separately track "first bytes" length in an instance variable
---
 .../org/apache/commons/io/input/BOMInputStream.java    | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

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 2caf29760..e7b6c3c47 100644
--- a/src/main/java/org/apache/commons/io/input/BOMInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/BOMInputStream.java
@@ -229,7 +229,6 @@ public static Builder builder() {
 
     private ByteOrderMark byteOrderMark;
     private int fbIndex;
-    private int fbLength;
     private int[] firstBytes;
     private final boolean include;
     private boolean markedAtStart;
@@ -458,26 +457,27 @@ public int read(final byte[] buf, int off, int len) throws IOException {
     }
 
     private ByteOrderMark readBom() throws IOException {
-        fbLength = 0;
+        int fbLength = 0;
         // BOMs are sorted from longest to shortest
         final int maxBomSize = bomList.get(0).length();
-        firstBytes = new int[maxBomSize];
+        final int[] tmp = new int[maxBomSize];
         // Read first maxBomSize bytes
-        for (int i = 0; i < firstBytes.length; i++) {
-            firstBytes[i] = in.read();
-            afterRead(firstBytes[i]);
+        for (int i = 0; i < tmp.length; i++) {
+            tmp[i] = in.read();
+            afterRead(tmp[i]);
             fbLength++;
-            if (firstBytes[i] < 0) {
+            if (tmp[i] < 0) {
                 break;
             }
         }
+        firstBytes = Arrays.copyOf(tmp, fbLength);
         // match BOM in firstBytes
         final ByteOrderMark bom = find();
         if (bom != null && !include) {
             if (bom.length() < firstBytes.length) {
                 fbIndex = bom.length();
             } else {
-                fbLength = 0;
+                firstBytes = new int[0];
             }
         }
         return bom;
@@ -494,7 +494,7 @@ private ByteOrderMark readBom() throws IOException {
      */
     private int readFirstBytes() throws IOException {
         getBOM();
-        return fbIndex < fbLength ? firstBytes[fbIndex++] : EOF;
+        return fbIndex < firstBytes.length ? firstBytes[fbIndex++] : EOF;
     }
 
     /**


(commons-io) 01/02: Reduce vertical whitespace

Posted by gg...@apache.org.
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 99aad6d3d3de10466b713fa88a1e4e8901bec38f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 1 16:20:06 2025 -0400

    Reduce vertical whitespace
---
 src/conf/spotbugs-exclude-filter.xml | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml
index 39103a78f..2c8007592 100644
--- a/src/conf/spotbugs-exclude-filter.xml
+++ b/src/conf/spotbugs-exclude-filter.xml
@@ -19,7 +19,6 @@
     xmlns="https://github.com/spotbugs/filter/3.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
-
   <!-- TODO Can any of these be done without breaking binary compatibility? -->
   <Match>
     <Class name="~.*" />
@@ -29,20 +28,17 @@
       <Bug pattern="MS_EXPOSE_REP" />
     </Or>
   </Match>
-
   <!-- https://github.com/spotbugs/spotbugs/issues/2710 -->
   <Match>
     <Class name="~.*" />
     <Bug pattern="CT_CONSTRUCTOR_THROW" />
   </Match>
-
   <!--  See discussion on https://issues.apache.org/jira/browse/IO-216 -->
   <Match>
     <Class name="org.apache.commons.io.output.LockableFileWriter" />
     <Method name="close" params="" returns="void" />
     <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
   </Match>
-
   <!-- The constructors intentionally do not copy the input byte array -->
   <Match>
     <Class name="org.apache.commons.io.input.UnsynchronizedByteArrayInputStream" />
@@ -64,33 +60,28 @@
     <Class name="org.apache.commons.io.output.NullPrintStream" />
     <Bug pattern="DM_DEFAULT_ENCODING" />
   </Match>
-
   <!-- Deprecated -->
   <Match>
     <Class name="org.apache.commons.io.file.PathUtils" />
     <Field name="NOFOLLOW_LINK_OPTION_ARRAY" />
     <Bug pattern="MS_PKGPROTECT" />
   </Match>
-
   <!-- Deprecated -->
   <Match>
     <Class name="org.apache.commons.io.monitor.FileAlterationObserver" />
     <Field name="fileFilter" />
     <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
   </Match>
-
   <!-- Deprecated -->
   <Match>
     <Class name="org.apache.commons.io.monitor.FileAlterationObserver" />
     <Field name="listeners" />
     <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
   </Match>
-
   <!-- This class only throws unchecked exceptions. -->
   <Match>
     <Class name="org.apache.commons.io.function.UncheckedIOIterator" />
     <Method name="next" />
     <Bug pattern="IT_NO_SUCH_ELEMENT" />
   </Match>
-
 </FindBugsFilter>