Skip to content

Commit

Permalink
Need to keep inputstream open until used
Browse files Browse the repository at this point in the history
  • Loading branch information
basiliskus committed Oct 1, 2024
1 parent d10c96d commit 8b6fc12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public List<HL7FileStream> fetchFiles() {
.filter(path -> path.toString().endsWith(EXTENSION))
.map(
p -> {
try (InputStream inputStream = Files.newInputStream(p)) {
try {
// Need to keep the input stream open until the test is done
// Must make sure to close the input stream after use
InputStream inputStream = Files.newInputStream(p);
return new HL7FileStream(
p.getFileName().toString(), inputStream);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class AutomatedTest extends Specification {
TestApplicationContext.injectRegisteredImplementations()
}

def cleanup() {
for (HL7FileStream fileStream : recentLocalFiles + recentAzureFiles) {
fileStream.inputStream().close()
}
}

def "test defined assertions on relevant messages"() {
given:
Expand Down

0 comments on commit 8b6fc12

Please sign in to comment.