Skip to content

Commit

Permalink
[bugfix] prevent resource leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
dizzzz committed Oct 22, 2021
1 parent 440984c commit 7ab1528
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 7ab1528

Please sign in to comment.