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

[java] Avoid FileInputStream and FileOutputStream #1439

merged 1 commit into from Dec 8, 2018


None yet
2 participants
Copy link

reudismam commented Nov 6, 2018

Avoid FileInputStream and FileOutputStream. These classes override the finalize method. As a result, their objects are only cleaned when the garbage collector performs a sweep. Since Java 7, programmers can use Files.newInputStream and Files.newOutputStream instead of FileInputStream and FileOutputStream to improve performance.

Copy link

adangel left a comment

@reudismam Thanks for the PR and sorry for the late feedback.
Could you have a look at the failing unit tests? It seems, that the API is unfortunately not directly compatible, since Files.newInputStream throws a java.nio.file.NoSuchFileException instead of a (both are IOExceptions though).

You can see the failing tests in the travis build:


This comment has been minimized.

Copy link

adangel commented Nov 20, 2018

This is a basically the rule AvoidFileStream applied on our code base - we should add it to our dogfood ruleset...

@adangel adangel changed the title [Java] Avoid FileInputStream and FileOutputStream. [java] Avoid FileInputStream and FileOutputStream Nov 20, 2018

adangel added a commit to pmd/build-tools that referenced this pull request Nov 21, 2018

@adangel adangel added the is:WIP label Nov 21, 2018

@adangel adangel added this to the 6.10.0 milestone Nov 29, 2018

adangel added a commit to adangel/pmd that referenced this pull request Dec 4, 2018

@adangel adangel removed the is:WIP label Dec 7, 2018


This comment has been minimized.

Copy link

adangel commented Dec 7, 2018

The requested changes have been taken care of with #1491

@adangel adangel merged commit 5ec39e9 into pmd:master Dec 8, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment