Skip to content

Commit 45e7ddd

Browse files
committed
Narrow allowable Exceptions
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1003571 13f79535-47bb-0310-9956-ffa450edef68
1 parent ba7b754 commit 45e7ddd

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/test/org/apache/commons/io/FileUtilsListFilesTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ public void testListFiles() throws Exception {
163163
try {
164164
FileUtils.listFiles(getLocalTestDirectory(), (IOFileFilter)null, (IOFileFilter)null);
165165
fail("Expected error about null parameter");
166-
} catch (Exception e) {
167-
//fine
166+
} catch (NullPointerException e) {
167+
// expected
168168
}
169169
}
170170

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void testMarkAndReset() throws Exception {
151151
try {
152152
input.reset();
153153
fail("Read limit exceeded, expected IOException ");
154-
} catch (Exception e) {
154+
} catch (IOException e) {
155155
assertEquals("No Mark IOException message",
156156
"No position has been marked",
157157
e.getMessage());
@@ -181,7 +181,7 @@ public void testMarkAndReset() throws Exception {
181181
try {
182182
input.reset();
183183
fail("Read limit exceeded, expected IOException ");
184-
} catch (Exception e) {
184+
} catch (IOException e) {
185185
assertEquals("Read limit IOException message",
186186
"Marked position [" + position
187187
+ "] is no longer valid - passed the read limit ["
@@ -226,7 +226,7 @@ public void testSkip() throws Exception {
226226
try {
227227
input.skip(5); //
228228
fail("Expected IOException for skipping after end of file");
229-
} catch (Exception e) {
229+
} catch (IOException e) {
230230
assertEquals("Skip after EOF IOException message",
231231
"Skip after end of file",
232232
e.getMessage());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void testMarkAndReset() throws Exception {
148148
try {
149149
reader.reset();
150150
fail("Read limit exceeded, expected IOException ");
151-
} catch (Exception e) {
151+
} catch (IOException e) {
152152
assertEquals("No Mark IOException message",
153153
"No position has been marked",
154154
e.getMessage());
@@ -178,7 +178,7 @@ public void testMarkAndReset() throws Exception {
178178
try {
179179
reader.reset();
180180
fail("Read limit exceeded, expected IOException ");
181-
} catch (Exception e) {
181+
} catch (IOException e) {
182182
assertEquals("Read limit IOException message",
183183
"Marked position [" + position
184184
+ "] is no longer valid - passed the read limit ["
@@ -223,7 +223,7 @@ public void testSkip() throws Exception {
223223
try {
224224
reader.skip(5); //
225225
fail("Expected IOException for skipping after end of file");
226-
} catch (Exception e) {
226+
} catch (IOException e) {
227227
assertEquals("Skip after EOF IOException message",
228228
"Skip after end of file",
229229
e.getMessage());

0 commit comments

Comments
 (0)