Incorrect "AutoCloseable used without 'try'-with-resources" warning for append call?
Answered
Incorrect "AutoCloseable used without 'try'-with-resources" warning for append call for following code? (IU-143.2287, Intellij IDEA Ultimate 15.0.4 (lame you can't copy this from the About screen too), JDK 8 on OS X Mavericks 10.9.5).
static void foo() throws IOException {
try(BufferedWriter wr = new BufferedWriter(new FileWriter("foo.txt"))) {
wr.append("bar"); // <- produces warning
}
}
Please sign in to leave a comment.
Just noticed if i check "Ignore AutoCloseable instances returned from method calls" it goes away, but it still seems spurious to me when that's unchecked.
> lame you can't copy this from the About screen too
Actually, you can: https://youtrack.jetbrains.com/issue/IDEA-70737.
I'll be damned - thank you; it's not at all clear UI-wise.
Would be cool if you could just select the text; that applies elsewhere too like in the preferences menu when i want to copy the preference name for a bug report.
Selecting text in About dialog is not an easy task to implement, see https://youtrack.jetbrains.com/issue/IDEA-152558 why. IDEA 16 already displays a hint that you can copy the info from About dialog.
I sympathize with reporter's (https://youtrack.jetbrains.com/issue/IDEA-152558 ) desire to copy as much text as possible but am by no means a UI expert or product manager and appreciate the complexity - value tradeoffs - thanks for the feedback!
Any ideas on my real question would be cool :)
> Any ideas on my real question would be cool :)
I've asked the responsible developer to have a look.
Please see https://youtrack.jetbrains.com/issue/IDEA-133999. It should be fixed in IDEA 16: https://confluence.jetbrains.com/display/IDEADEV/IDEA+2016.1+EAP.
awesome - thanks Serge!
This has come back (or it never went away). I see it in IDEA 2022.1.3 (Ultimate Edition), Build #IU-221.5921.22, built on June 21, 2022.
As a work-around, I have enabled "Ignore AutoCloseable instances returned from method calls" checkbox in the inspection's settings (File -> Settings -> Editor -> Inspections -> Java -> Resource Management -> AutoCloseable ...).
Craig Larsen the issue is not reproduced for me with the sample code posted above in 2022.1.3 and 2022.2 EAP 7. Could you please share your code sample?