Fortify将try-with-resources标记为中等严重性问题

时间:2017-07-27 20:59:58

标签: java fortify

我已经生成了强化代码审查,并且我在最终关闭FileStream(在try-with-resources块中)和file.delete时获得了中等严重性。如何删除这些问题?

Category    Detail  Location    Severity
Poor Error Handling : Throw Inside Finally  FinallyBlock classA.java:108    Medium
Poor Error Handling : Throw Inside Finally  FinallyBlock    classB.java:87  Medium

ClassA.java:108

try (OutputStream recordsFileOut = new FileOutputStream(downloadFile.toFile());
     OutputStream rejectedFileOut = new FileOutputStream(rejectedRecordsFile.toFile())) {


      ......


}

classB.java:87

try {

} catch(IOException ex) {


} finally {
    outputFile.toFile().delete();
}

1 个答案:

答案 0 :(得分:0)

从您显示的代码中我只能推断出outputFile.toFile()必须抛出一些可捕获的异常。这将导致绕过.delete(),这必定是Fortify所抱怨的。

有关详细信息,请参阅this page