-
Notifications
You must be signed in to change notification settings - Fork 55
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
false positive: Suggests to prefer Files.newOutputStream
when FileOutputStream
is needed
#302
Comments
Unfortunately CC @mkarg who introduced this violation. Any suggestions if we can improve this situation or force users to suppress violations? |
@McPringle Hello Marcus, I know that code line (in fact I used Apus for a beta test befor committing the NIO fixes for Modernizer) and already wanted to propose to get rid of the Channel recently, but forgot to ask you on our last telco on Friday! Let's discuss the solution out-of-bands. The solution should be as-easy-as using @gaul Nobody should be forced to keep |
Files.newOutputStream
when FileOutputStream
is neededFiles.newOutputStream
when FileOutputStream
is needed
Thank you for your explanation, @mkarg. Maybe the message could be made more clear about that. Or should the modernizer plugin mention the problem/solution in the line containing |
The use of |
@gaul Proposing to close this issue, as the question is answered. In the exception case where a violation is to be ignored, the code location can be annotated. |
In my project I have a method which requires a
FileOutputStream
:The code in question is the second variable in the try-with-resources statement:
The output of the modernizer plugin during the build:
In this case, the
FileOutputStream
is mandatory and can't be replaced by aOutputStream
. That breaks the following logic in this method (use oftransferFrom
).Link to source file in repo: https://github.com/McPringle/apus/blob/e5b2ab3124250ca7bcf61e40e34987aa0fe34e27/src/main/java/swiss/fihlon/apus/plugin/event/jfs/JavaForumStuttgartPlugin.java#L114
Steps to reproduce:
git clone https://github.com/McPringle/apus.git
cd apus
./mvnw verify
Attention: In the latest commit I added the
@SuppressModernizer
in line 105. You have to remove it first, to reproduce the error message!The text was updated successfully, but these errors were encountered: