Skip to content

Commit 083c584

Browse files
author
Gary Gregory
committed
Remove IOException from the method signatures that no longer
throw IOException. This maintains binary compatibility but not source compatibility. - FilenameUtils directoryContains(String, String) - BoundedReader BoundedReader(java.io.Reader, int) - IOUtils lineIterator(java.io.InputStream, Charset) lineIterator(java.io.InputStream, String) toByteArray(String) toInputStream(CharSequence, String) toInputStream(String, String) toString(byte[]) toString(byte[], String)
1 parent 35d7843 commit 083c584

4 files changed

Lines changed: 28 additions & 20 deletions

File tree

src/changes/changes.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ The <action> type attribute can be add,update,fix,remove.
5959
<action dev="ggregory" type="fix" due-to="Arturo Bernal">
6060
Replace construction of FileInputStream and FileOutputStream objects with Files NIO APIs. #221.
6161
</action>
62+
<action dev="ggregory" type="fix" due-to="Gary Gregory">
63+
Fix IndexOutOfBoundsException in IOExceptionList constructors.
64+
</action>
65+
<action dev="ggregory" type="fix" due-to="Gary Gregory">
66+
Remove IOException from the method signatures that no longer throw IOException.
67+
This maintains binary compatibility but not source compatibility.
68+
- FilenameUtils
69+
directoryContains(String, String)
70+
- BoundedReader
71+
BoundedReader(java.io.Reader, int)
72+
- IOUtils
73+
lineIterator(java.io.InputStream, Charset)
74+
lineIterator(java.io.InputStream, String)
75+
toByteArray(String)
76+
toInputStream(CharSequence, String)
77+
toInputStream(String, String)
78+
toString(byte[])
79+
toString(byte[], String)
80+
</action>
6281
<!-- ADD -->
6382
<action dev="ggregory" type="update" due-to="Gary Gregory">
6483
Add SymbolicLinkFileFilter.

src/main/java/org/apache/commons/io/FilenameUtils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.commons.io;
1818

1919
import java.io.File;
20-
import java.io.IOException;
2120
import java.util.ArrayDeque;
2221
import java.util.ArrayList;
2322
import java.util.Arrays;
@@ -533,12 +532,10 @@ public static String concat(final String basePath, final String fullFileNameToAd
533532
* @param canonicalChild
534533
* the file to consider as the child.
535534
* @return true is the candidate leaf is under by the specified composite. False otherwise.
536-
* @throws IOException Never thrown.
537535
* @since 2.2
538536
* @see FileUtils#directoryContains(File, File)
539537
*/
540-
public static boolean directoryContains(final String canonicalParent, final String canonicalChild)
541-
throws IOException {
538+
public static boolean directoryContains(final String canonicalParent, final String canonicalChild) {
542539
Objects.requireNonNull(canonicalParent, "canonicalParent");
543540

544541
if (canonicalChild == null) {

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,10 +1594,9 @@ public static int length(final Object[] array) {
15941594
* @param charset the charset to use, null means platform default
15951595
* @return an Iterator of the lines in the reader, never null
15961596
* @throws IllegalArgumentException if the input is null
1597-
* @throws IOException Never thrown.
15981597
* @since 2.3
15991598
*/
1600-
public static LineIterator lineIterator(final InputStream input, final Charset charset) throws IOException {
1599+
public static LineIterator lineIterator(final InputStream input, final Charset charset) {
16011600
return new LineIterator(new InputStreamReader(input, Charsets.toCharset(charset)));
16021601
}
16031602

@@ -1628,13 +1627,12 @@ public static LineIterator lineIterator(final InputStream input, final Charset c
16281627
* @param charsetName the encoding to use, null means platform default
16291628
* @return an Iterator of the lines in the reader, never null
16301629
* @throws IllegalArgumentException if the input is null
1631-
* @throws IOException if an I/O error occurs, such as if the encoding is invalid
16321630
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
16331631
* .UnsupportedEncodingException} in version 2.2 if the
16341632
* encoding is not supported.
16351633
* @since 1.2
16361634
*/
1637-
public static LineIterator lineIterator(final InputStream input, final String charsetName) throws IOException {
1635+
public static LineIterator lineIterator(final InputStream input, final String charsetName) {
16381636
return lineIterator(input, Charsets.toCharset(charsetName));
16391637
}
16401638

@@ -2543,11 +2541,10 @@ public static byte[] toByteArray(final Reader reader, final String charsetName)
25432541
* @param input the {@code String} to convert
25442542
* @return the requested byte array
25452543
* @throws NullPointerException if the input is null
2546-
* @throws IOException Never thrown.
25472544
* @deprecated 2.5 Use {@link String#getBytes()} instead
25482545
*/
25492546
@Deprecated
2550-
public static byte[] toByteArray(final String input) throws IOException {
2547+
public static byte[] toByteArray(final String input) {
25512548
// make explicit the use of the default charset
25522549
return input.getBytes(Charset.defaultCharset());
25532550
}
@@ -2717,13 +2714,12 @@ public static InputStream toInputStream(final CharSequence input, final Charset
27172714
* @param input the CharSequence to convert
27182715
* @param charsetName the name of the requested charset, null means platform default
27192716
* @return an input stream
2720-
* @throws IOException Never thrown.
27212717
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
27222718
* .UnsupportedEncodingException} in version 2.2 if the
27232719
* encoding is not supported.
27242720
* @since 2.0
27252721
*/
2726-
public static InputStream toInputStream(final CharSequence input, final String charsetName) throws IOException {
2722+
public static InputStream toInputStream(final CharSequence input, final String charsetName) {
27272723
return toInputStream(input, Charsets.toCharset(charsetName));
27282724
}
27292725

@@ -2764,13 +2760,12 @@ public static InputStream toInputStream(final String input, final Charset charse
27642760
* @param input the string to convert
27652761
* @param charsetName the name of the requested charset, null means platform default
27662762
* @return an input stream
2767-
* @throws IOException Never thrown.
27682763
* @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io
27692764
* .UnsupportedEncodingException} in version 2.2 if the
27702765
* encoding is not supported.
27712766
* @since 1.1
27722767
*/
2773-
public static InputStream toInputStream(final String input, final String charsetName) throws IOException {
2768+
public static InputStream toInputStream(final String input, final String charsetName) {
27742769
final byte[] bytes = input.getBytes(Charsets.toCharset(charsetName));
27752770
return new ByteArrayInputStream(bytes);
27762771
}
@@ -2782,11 +2777,10 @@ public static InputStream toInputStream(final String input, final String charset
27822777
* @param input the byte array to read from
27832778
* @return the requested String
27842779
* @throws NullPointerException if the input is null
2785-
* @throws IOException Never thrown.
27862780
* @deprecated 2.5 Use {@link String#String(byte[])} instead
27872781
*/
27882782
@Deprecated
2789-
public static String toString(final byte[] input) throws IOException {
2783+
public static String toString(final byte[] input) {
27902784
// make explicit the use of the default charset
27912785
return new String(input, Charset.defaultCharset());
27922786
}
@@ -2802,9 +2796,8 @@ public static String toString(final byte[] input) throws IOException {
28022796
* @param charsetName the name of the requested charset, null means platform default
28032797
* @return the requested String
28042798
* @throws NullPointerException if the input is null
2805-
* @throws IOException Never thrown.
28062799
*/
2807-
public static String toString(final byte[] input, final String charsetName) throws IOException {
2800+
public static String toString(final byte[] input, final String charsetName) {
28082801
return new String(input, Charsets.toCharset(charsetName));
28092802
}
28102803

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ public class BoundedReader extends Reader {
5353
*
5454
* @param target The target stream that will be used
5555
* @param maxCharsFromTargetReader The maximum number of characters that can be read from target
56-
* @throws IOException Never thrown.
5756
*/
58-
public BoundedReader(final Reader target, final int maxCharsFromTargetReader) throws IOException {
57+
public BoundedReader(final Reader target, final int maxCharsFromTargetReader) {
5958
this.target = target;
6059
this.maxCharsFromTargetReader = maxCharsFromTargetReader;
6160
}

0 commit comments

Comments
 (0)