: -
ここ
BufferedReader br = null;
String queryTemplate = null;
try {
br = new BufferedReader(new FileReader(queryFile));
queryTemplate = br.readLine();
} catch (FileNotFoundException e) {
// throw exception
} catch (IOException e) {
// throw exception
} finally {
br.close();
}
、br
BufferedReaderのはbr.close()
でnull
ことができます。ただし、が失敗した場合は、null
にしかなりません。この場合、関連する例外がスローされます。
これは誤った警告です。Findbugs
ドキュメントには次のように記載されています。 -
This may lead to a NullPointerException when the code is executed.
Note that because FindBugs currently does not prune infeasible
exception paths, this may be a false warning.
推奨事項が表示されている場所にコードを投稿してください。 – SiB
このfindbugsルールに関するサンプルコードを見たいと思います。私はそれを一般的に知りたい。 –