Skip to content

Commit 49f8c2a

Browse files
committed
Revert "IO-469 Self-supression with try-with-resources"
Things are not as simple as they might seem git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1686460 13f79535-47bb-0310-9956-ffa450edef68
1 parent ed17234 commit 49f8c2a

4 files changed

Lines changed: 2 additions & 31 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public synchronized void reset() throws IOException {
102102
*/
103103
@Override
104104
public void close() throws IOException {
105-
throw new IOException(exception.getMessage());
105+
throw exception;
106106
}
107107

108108
}

src/main/java/org/apache/commons/io/output/BrokenOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void flush() throws IOException {
7979
*/
8080
@Override
8181
public void close() throws IOException {
82-
throw new IOException(exception.getMessage());
82+
throw exception;
8383
}
8484

8585
}

src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,4 @@ public void testClose() {
9595
}
9696
}
9797

98-
@SuppressWarnings("ResultOfMethodCallIgnored")
99-
public void testSelfSupressed(){
100-
BrokenInputStream bis = new BrokenInputStream();
101-
try {
102-
bis.read();
103-
} catch (IOException e) {
104-
try {
105-
bis.close();
106-
} catch (IOException e1) {
107-
e1.addSuppressed( e); // Simulates try-with resources since we're not jdk7 yet
108-
}
109-
}
110-
}
111-
11298
}

src/test/java/org/apache/commons/io/output/BrokenOutputStreamTest.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.OutputStream;
2121

2222
import junit.framework.TestCase;
23-
import org.apache.commons.io.input.BrokenInputStream;
2423

2524
/**
2625
* JUnit Test Case for {@link BrokenOutputStream}.
@@ -78,18 +77,4 @@ public void testClose() {
7877
}
7978
}
8079

81-
@SuppressWarnings("ResultOfMethodCallIgnored")
82-
public void testSelfSupressed(){
83-
BrokenOutputStream bos = new BrokenOutputStream();
84-
try {
85-
bos.write(123);
86-
} catch (IOException e) {
87-
try {
88-
bos.close();
89-
} catch (IOException e1) {
90-
e1.addSuppressed( e); // Simulates try-with resources since we're not jdk7 yet
91-
}
92-
}
93-
}
94-
9580
}

0 commit comments

Comments
 (0)