Skip to content

Commit a0e069d

Browse files
committed
[IO-868] BoundedInputStream builder() can throw IOException
- Javadoc improvements - Remove some @SuppressWarnings("resource")
1 parent 42d0c36 commit a0e069d

36 files changed

+93
-66
lines changed

src/main/java/org/apache/commons/io/function/IOSupplier.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ default Supplier<T> asSupplier() {
4848
*
4949
* @return a result.
5050
* @throws IOException if an I/O error occurs.
51+
* @see #getUnchecked()
5152
*/
5253
T get() throws IOException;
5354

@@ -56,6 +57,7 @@ default Supplier<T> asSupplier() {
5657
*
5758
* @return a result.
5859
* @throws UncheckedIOException if an I/O error occurs.
60+
* @see #get()
5961
* @since 2.17.0
6062
*/
6163
default T getUnchecked() throws UncheckedIOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public Builder() {
7272
/**
7373
* Builds a new {@link AutoCloseInputStream}.
7474
* <p>
75-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
75+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
7676
* </p>
7777
* <p>
78-
* This builder use the following aspects:
78+
* This builder uses the following aspects:
7979
* </p>
8080
* <ul>
8181
* <li>{@link #getInputStream()}</li>
@@ -86,6 +86,7 @@ public Builder() {
8686
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
8787
* @throws IOException if an I/O error occurs.
8888
* @see #getInputStream()
89+
* @see #getUnchecked()
8990
*/
9091
@Override
9192
public AutoCloseInputStream get() throws IOException {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ public Builder() {
151151
/**
152152
* Builds a new {@link BOMInputStream}.
153153
* <p>
154-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
154+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
155155
* </p>
156156
* <p>
157-
* This builder use the following aspects: InputStream, OpenOption[], include, and ByteOrderMark[].
157+
* This builder uses the following aspects: InputStream, OpenOption[], include, and ByteOrderMark[].
158158
* </p>
159159
* <p>
160-
* This builder use the following aspects:
160+
* This builder uses the following aspects:
161161
* </p>
162162
* <ul>
163163
* <li>{@link #getInputStream()}</li>
@@ -170,6 +170,7 @@ public Builder() {
170170
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
171171
* @throws IOException if an I/O error occurs.
172172
* @see #getInputStream()
173+
* @see #getUnchecked()
173174
*/
174175
@Override
175176
public BOMInputStream get() throws IOException {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,16 @@ public Builder() {
252252
/**
253253
* Builds a new {@link BoundedInputStream}.
254254
* <p>
255-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
255+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
256256
* </p>
257257
* <p>
258-
* This builder use the following aspects:
258+
* If you start from an input stream, an exception can't be thrown, and you can call {@link #getUnchecked()} instead.
259+
* </p>
260+
* <p>
261+
* This builder uses the following aspects:
259262
* </p>
260263
* <ul>
261-
* <li>{@link #getInputStream()}</li>
264+
* <li>{@link #getInputStream()} (the target aspect)</li>
262265
* <li>{@link #getAfterRead()}</li>
263266
* <li>{@link #getCount()}</li>
264267
* <li>{@link #getMaxCount()}</li>
@@ -269,8 +272,9 @@ public Builder() {
269272
* @return a new instance.
270273
* @throws IllegalStateException if the {@code origin} is {@code null}.
271274
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
272-
* @throws IOException if an I/O error occurs.
275+
* @throws IOException if an I/O error occurs converting to an {@link InputStream} using {@link #getInputStream()}.
273276
* @see #getInputStream()
277+
* @see #getUnchecked()
274278
*/
275279
@Override
276280
public BoundedInputStream get() throws IOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ public Builder() {
8585
/**
8686
* Builds a new {@link BufferedFileChannelInputStream}.
8787
* <p>
88-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
88+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
8989
* </p>
9090
* <p>
91-
* This builder use the following aspects:
91+
* This builder uses the following aspects:
9292
* </p>
9393
* <ul>
9494
* <li>{@link #getInputStream()}</li>
@@ -101,6 +101,7 @@ public Builder() {
101101
* @throws IOException If an I/O error occurs
102102
* @see #getPath()
103103
* @see #getBufferSize()
104+
* @see #getUnchecked()
104105
*/
105106
@Override
106107
public BufferedFileChannelInputStream get() throws IOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ public Builder() {
9595
/**
9696
* Builds a new {@link CharSequenceInputStream}.
9797
* <p>
98-
* You must set input that supports {@link #getCharSequence()}, otherwise, this method throws an exception.
98+
* You must set an aspect that supports {@link #getCharSequence()}, otherwise, this method throws an exception.
9999
* </p>
100100
* <p>
101-
* This builder use the following aspects:
101+
* This builder uses the following aspects:
102102
* </p>
103103
* <ul>
104104
* <li>{@link #getCharSequence()}</li>
@@ -108,6 +108,7 @@ public Builder() {
108108
*
109109
* @return a new instance.
110110
* @throws IllegalArgumentException if the buffer is not large enough to hold a complete character.
111+
* @see #getUnchecked()
111112
*/
112113
@Override
113114
public CharSequenceInputStream get() {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ public Builder() {
128128
/**
129129
* Builds a new {@link ChecksumInputStream}.
130130
* <p>
131-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
131+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
132132
* </p>
133133
* <p>
134-
* This builder use the following aspects:
134+
* This builder uses the following aspects:
135135
* </p>
136136
* <ul>
137137
* <li>{@link #getInputStream()}</li>
@@ -145,6 +145,7 @@ public Builder() {
145145
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
146146
* @throws IOException if an I/O error occurs.
147147
* @see #getInputStream()
148+
* @see #getUnchecked()
148149
*/
149150
@Override
150151
public ChecksumInputStream get() throws IOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public Builder() {
102102
/**
103103
* Builds a new {@link MemoryMappedFileInputStream}.
104104
* <p>
105-
* You must set input that supports {@link #getPath()}, otherwise, this method throws an exception.
105+
* You must set an aspect that supports {@link #getPath()}, otherwise, this method throws an exception.
106106
* </p>
107107
* <p>
108-
* This builder use the following aspects:
108+
* This builder uses the following aspects:
109109
* </p>
110110
* <ul>
111111
* <li>{@link #getPath()}</li>
@@ -118,6 +118,7 @@ public Builder() {
118118
* @throws IOException if an I/O error occurs.
119119
* @see #getPath()
120120
* @see #getBufferSize()
121+
* @see #getUnchecked()
121122
*/
122123
@Override
123124
public MemoryMappedFileInputStream get() throws IOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ public Builder() {
8686
/**
8787
* Builds a new {@link MessageDigestCalculatingInputStream}.
8888
* <p>
89-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
89+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
9090
* </p>
9191
* <p>
92-
* This builder use the following aspects:
92+
* This builder uses the following aspects:
9393
* </p>
9494
* <ul>
9595
* <li>{@link #getPath()}</li>
@@ -102,6 +102,7 @@ public Builder() {
102102
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
103103
* @throws IOException if an I/O error occurs.
104104
* @see #getInputStream()
105+
* @see #getUnchecked()
105106
*/
106107
@Override
107108
public MessageDigestCalculatingInputStream get() throws IOException {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ public Builder() {
8585
/**
8686
* Builds new {@link MessageDigestInputStream}.
8787
* <p>
88-
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
88+
* You must set an aspect that supports {@link #getInputStream()}, otherwise, this method throws an exception.
8989
* </p>
9090
* <p>
91-
* This builder use the following aspects:
91+
* This builder uses the following aspects:
9292
* </p>
9393
* <ul>
9494
* <li>{@link #getPath()}</li>
@@ -101,6 +101,7 @@ public Builder() {
101101
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
102102
* @throws IOException if an I/O error occurs.
103103
* @see #getInputStream()
104+
* @see #getUnchecked()
104105
*/
105106
@Override
106107
public MessageDigestInputStream get() throws IOException {

0 commit comments

Comments
 (0)