我有以下代码:
/**
* Performs the filename extension check (command-line argument validity).
* @param valid True, if the check should be performed.
* @param filename File name to test.
* @return False, if the test was done and the filename does not end with
* ".xml". Value of valid otherwise.
*/
private boolean checkFileNameExtension(final boolean valid,
final String filename) {
boolean result = valid;
if (valid
&& !filename.toLowerCase(Locale.ENGLISH).endsWith(".xml")) {
this.logger.error("File doesn't have XML extension.");
result = false;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
FindBugs抱怨toLowerCase电话:
[WARNING] FindBugs: L I Dm: Use of non-localized String.toUpperCase() or
String.toLowerCase() in [...]checkFileNameExtension(boolean, String)
Run Code Online (Sandbox Code Playgroud)
如果我可以确定所有文件名始终只有拉丁字母的名称,我该如何正确修复该警告(正确的方法)?
添加Locale.ENGLISH(或Locale.ROOT)是修复错误的正确方法,因此如果FindBugs在添加错误后仍然报告该错误,那么您可能在FindBugs本身中发现了一个错误.
| 归档时间: |
|
| 查看次数: |
5133 次 |
| 最近记录: |