Skip to content

Commit 2112fab

Browse files
committed
Internal refactoring
1 parent a757448 commit 2112fab

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Builder() {
113113
*/
114114
@Override
115115
public UnsynchronizedBufferedInputStream get() throws IOException {
116-
return new UnsynchronizedBufferedInputStream(getInputStream(), getBufferSize());
116+
return new UnsynchronizedBufferedInputStream(this);
117117
}
118118

119119
}
@@ -147,16 +147,18 @@ public UnsynchronizedBufferedInputStream get() throws IOException {
147147
* Constructs a new {@code BufferedInputStream} on the {@link InputStream} {@code in}. The buffer size is specified by the parameter {@code size} and all
148148
* reads are now filtered through this stream.
149149
*
150-
* @param in the input stream the buffer reads from.
151-
* @param size the size of buffer to allocate.
150+
* @param builder A builder providing the input stream and buffer size.
151+
* @throws IOException if an I/O error occurs.
152152
* @throws IllegalArgumentException if {@code size < 0}.
153153
*/
154-
private UnsynchronizedBufferedInputStream(final InputStream in, final int size) {
155-
super(in);
156-
if (size <= 0) {
154+
@SuppressWarnings("resource")
155+
private UnsynchronizedBufferedInputStream(final Builder builder) throws IOException {
156+
super(builder.getInputStream());
157+
final int bufferSize = builder.getBufferSize();
158+
if (bufferSize <= 0) {
157159
throw new IllegalArgumentException("Size must be > 0");
158160
}
159-
buffer = new byte[size];
161+
buffer = new byte[bufferSize];
160162
}
161163

162164
/**

0 commit comments

Comments
 (0)