Skip to content

Commit

Permalink
Simplify try/finally block
Browse files Browse the repository at this point in the history
  • Loading branch information
dwnusbaum committed Apr 11, 2018
1 parent 3cc9fdc commit f92223d
Showing 1 changed file with 3 additions and 6 deletions.
Expand Up @@ -73,9 +73,8 @@ public void detectFileLeak() throws Exception {
@Test
public void detectPipeLeak() throws Exception {
activateFileLeakDetector();
Pipe p = null;
Pipe p = Pipe.open();
try {
p = Pipe.open();
assertThat("There should be a pipe sink and source channel opened by this method", getOpenDescriptors(), allOf(
hasItem(allOf(
containsString("Pipe Sink Channel by thread:"),
Expand All @@ -85,10 +84,8 @@ public void detectPipeLeak() throws Exception {
containsString("FileHandleDumpTest.detectPipeLeak(")
))));
} finally {
if (p != null) {
p.sink().close();
p.source().close();
}
p.sink().close();
p.source().close();
}
assertThat("There should not be a pipe sink or source channel opened by this method", getOpenDescriptors(), not(anyOf(
hasItem(allOf(
Expand Down

0 comments on commit f92223d

Please sign in to comment.