Strange “Resource leak: stream is never closed” with try-with-resources if Exception is thrown in a loop

前端 未结 1 819
清歌不尽
清歌不尽 2021-02-19 01:17

Why is Eclipse giving a strange \"Resource leak: zin is never closed\" warning for the following code even though I use try-with-resources:



        
1条回答
  •  走了就别回头了
    2021-02-19 01:46

    This appears to be a known bug in Eclipse: [compiler][resource] Bad resource leak problem on return inside while loop (resource passed on in finally block.

    I just got bit by this myself, and have added my vote on the tracker.

    Update: The above bug has been resolved in 4.5 M7. This will be included in the final release of Eclipse 4.5 ("Mars") - which looks on track to be released 2015-06-24.

    0 讨论(0)
提交回复
热议问题