Sonar violation: “Method may fail to close stream on exception”

前端 未结 4 1463
青春惊慌失措
青春惊慌失措 2021-01-28 00:15

I have this method:

 private void unZipElementsTo(String inputZipFileName, String destPath) throws FileNotFoundException, IOException {

        OutputStream out         


        
4条回答
  •  感动是毒
    2021-01-28 00:51

    That's right. The OutputStream.close() method can itself throw an exception. If this happens, e.g. on the 1st line of your finally{} block, then the other streams will be left open.

提交回复
热议问题