Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added java 9+ compatibility (bugfix & addition) #139

Merged
merged 14 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,9 @@ else if ( ( file.getName().endsWith( ".jar" ) || file.getName().endsWith( ".jmod
public void process( Path path )
throws IOException
{
final SortedSet<Path> files = new TreeSet<>();
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {

@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
return FileVisitResult.CONTINUE;
}
final SortedSet<Path> files = new TreeSet<>();

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
Expand All @@ -155,15 +151,23 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
for (final Path file : files) {
Finomosec marked this conversation as resolved.
Show resolved Hide resolved
try (final InputStream inputStream = Files.newInputStream(file)) {
Copy link
Member

@olamy olamy May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit.: why final? not sure if it helps anything here

Copy link
Contributor Author

@Finomosec Finomosec May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not intentional. Not harmful. It does not change the behavior here.

In my company we decided to make anything final, that can be final.
It's supposed to make the semantics of the code clearer when reading code.

Remove the finals if you want.

p.s. thanks for the merge.

process(file.toString(), inputStream);
}
}
files.clear();
return super.postVisitDirectory(dir, exc);
Finomosec marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}

});
for (final Path file : files) {
process(file.toString(), Files.newInputStream(file));
}
}

protected void processDirectory( File dir )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -85,7 +84,7 @@ public static void main( String[] args )

try {
files.add(Paths.get(new URI(args[i]))); // attempt to treat it as an URI
Finomosec marked this conversation as resolved.
Show resolved Hide resolved
} catch (URISyntaxException e) {
} catch (Exception e) {
Finomosec marked this conversation as resolved.
Show resolved Hide resolved
files.add(Paths.get(args[i])); // if that fails: treat is as a normal file/path
}
}
Expand Down