Skip to content

Commit

Permalink
Fix a potential resource leak
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Jul 21, 2023
1 parent a0b4092 commit 3c76fdc
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.smithy.build.FileManifest;
import software.amazon.smithy.build.PluginContext;
import software.amazon.smithy.build.SmithyBuildPlugin;
Expand Down Expand Up @@ -108,10 +109,11 @@ private static List<String> copySources(PluginContext context) {
private static void copyDirectory(List<String> names, FileManifest manifest, Path root, Path current) {
try {
if (Files.isDirectory(current)) {
Files.list(current)
.filter(p -> !p.equals(current))
.filter(p -> Files.isDirectory(p) || Files.isRegularFile(p))
.forEach(p -> copyDirectory(names, manifest, root, p));
try (Stream<Path> fileList = Files.list(current)) {
fileList.filter(p -> !p.equals(current))
.filter(p -> Files.isDirectory(p) || Files.isRegularFile(p))
.forEach(p -> copyDirectory(names, manifest, root, p));
}
} else if (Files.isRegularFile(current)) {
if (current.toString().endsWith(".jar")) {
// Account for just a simple file vs recursing into directories.
Expand Down

0 comments on commit 3c76fdc

Please sign in to comment.