Skip to content

Commit

Permalink
Use try-with-resources statement to close stream in any situation.
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-gerhardt committed Jul 10, 2024
1 parent e486991 commit 95577c3
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
Expand Down Expand Up @@ -253,9 +254,11 @@ public void testSave() throws Exception {

@Test
public void missingMetsHeaderCreationDateDidNotThrowNullPointerException() throws IOException {
Workpiece workpiece = new MetsXmlElementAccess()
.read(new FileInputStream("src/test/resources/meta_missing_createdate.xml"));
assertNotNull(workpiece.getCreationDate());
try (InputStream fileContent = new FileInputStream("src/test/resources/meta_missing_createdate.xml")) {
Workpiece workpiece = new MetsXmlElementAccess()
.read(fileContent);
assertNotNull(workpiece.getCreationDate());
}
}

@Test
Expand Down

0 comments on commit 95577c3

Please sign in to comment.