Skip to content

Commit d4f28d7

Browse files
committed
[IO-537] BOMInputStream shouldn't sort array of BOMs in-place.
1 parent f7a11c9 commit d4f28d7

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ The <action> type attribute can be add,update,fix,remove.
8383
<action issue="IO-503" dev="ggregory" type="fix">
8484
Update platform requirement to Java 7.
8585
</action>
86+
<action issue="IO-537" dev="ggregory" type="fix" due-to="Borys Zibrov">
87+
BOMInputStream shouldn't sort array of BOMs in-place.
88+
</action>
8689
<action issue="IO-506" dev="ggregory" type="update" due-to="Christian Schulte">
8790
Deprecate methods FileSystemUtils.freeSpaceKb().
8891
</action>

src/main/java/org/apache/commons/io/input/BOMInputStream.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.IOException;
2222
import java.io.InputStream;
2323
import java.util.Arrays;
24+
import java.util.Collections;
2425
import java.util.Comparator;
2526
import java.util.List;
2627

@@ -168,9 +169,10 @@ public BOMInputStream(final InputStream delegate, final boolean include, final B
168169
throw new IllegalArgumentException("No BOMs specified");
169170
}
170171
this.include = include;
172+
List<ByteOrderMark> list = Arrays.asList(boms);
171173
// Sort the BOMs to match the longest BOM first because some BOMs have the same starting two bytes.
172-
Arrays.sort(boms, ByteOrderMarkLengthComparator);
173-
this.boms = Arrays.asList(boms);
174+
Collections.sort(list, ByteOrderMarkLengthComparator);
175+
this.boms = list;
174176

175177
}
176178

0 commit comments

Comments
 (0)