Skip to content

Commit

Permalink
Merge pull request #4071 from dizzzz/bugfix/resource_leaks
Browse files Browse the repository at this point in the history
[bugfix] prevent resource leakage
  • Loading branch information
wolfgangmm authored Oct 28, 2021
2 parents 8487cc8 + 7ab1528 commit 6414413
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions exist-core/src/main/java/org/exist/repo/AutoDeploymentTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Startup trigger for automatic deployment of application packages. Scans the "autodeploy" directory
Expand Down Expand Up @@ -81,11 +86,11 @@ public void execute(final DBBroker sysBroker, final Txn transaction, final Map<S
return;
}

try {
final List<Path> xars = Files
.find(autodeployDir, 1, (path, attrs) -> (!attrs.isDirectory()) && FileUtils.fileName(path).endsWith(".xar"))
.sorted(Comparator.comparing(Path::getFileName))
.collect(Collectors.toList());
try (Stream<Path> xarsStream = Files
.find(autodeployDir, 1, (path, attrs) -> (!attrs.isDirectory()) && FileUtils.fileName(path).endsWith(".xar"))
.sorted(Comparator.comparing(Path::getFileName))) {

final List<Path> xars = xarsStream.collect(Collectors.toList());

LOG.info("Scanning autodeploy directory. Found {} app packages.", xars.size());

Expand Down

0 comments on commit 6414413

Please sign in to comment.