Skip to content

Commit

Permalink
Properly close DirectoryStream (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
britter authored Mar 19, 2020
1 parent cb7ae05 commit 48c8420
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -139,10 +140,10 @@ public static void writeStaleData( Commandline cmd, Path path )

private static Collection<Path> walk( Path dir )
{
try
Collection<Path> paths = new ArrayList<>();
try ( DirectoryStream<Path> directoryStream = Files.newDirectoryStream( dir ) )
{
Collection<Path> paths = new ArrayList<>();
for ( Path p : Files.newDirectoryStream( dir ) )
for ( Path p : directoryStream )
{
paths.add( p );
}
Expand Down

0 comments on commit 48c8420

Please # to comment.