Skip to content

Commit 9c2c0c7

Browse files
committed
(#64) Remove useless state from AutoClosedInputStream
1 parent 2eea8e6 commit 9c2c0c7

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/main/java/org/cactoos/http/io/AutoClosedInputStream.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public final class AutoClosedInputStream extends InputStream {
3838
*/
3939
private final InputStream origin;
4040

41-
/**
42-
* If the stream has been closed.
43-
*/
44-
private boolean closed;
45-
4641
/**
4742
* Cotr.
4843
*
@@ -55,10 +50,7 @@ public AutoClosedInputStream(final InputStream origin) {
5550

5651
@Override
5752
public void close() throws IOException {
58-
if (!this.closed) {
59-
this.origin.close();
60-
this.closed = true;
61-
}
53+
this.origin.close();
6254
}
6355

6456
@Override
@@ -115,13 +107,9 @@ private final class AutoClosed implements IntScalar {
115107
@Override
116108
public int value() throws IOException {
117109
final int ret;
118-
if (AutoClosedInputStream.this.closed) {
119-
ret = -1;
120-
} else {
121-
ret = this.origin.value();
122-
if (ret < 0) {
123-
AutoClosedInputStream.this.close();
124-
}
110+
ret = this.origin.value();
111+
if (ret < 0) {
112+
AutoClosedInputStream.this.close();
125113
}
126114
return ret;
127115
}

0 commit comments

Comments
 (0)