Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sonarqube squid:S2259和Apache Commons_Sonarqube - Fatal编程技术网

Sonarqube squid:S2259和Apache Commons

Sonarqube squid:S2259和Apache Commons,sonarqube,Sonarqube,考虑以下代码: private boolean hasEnabledBluetooth() { final BluetoothAdapter bluetoothAdapter = getBluetoothAdapter(); Validate.notNull(bluetoothAdapter); return bluetoothAdapter.isEnabled(); } 最后一行,返回bluetoothAdapter.isEnabled(),触发squid:S2259

考虑以下代码:

private boolean hasEnabledBluetooth() {
    final BluetoothAdapter bluetoothAdapter = getBluetoothAdapter();
    Validate.notNull(bluetoothAdapter);
    return bluetoothAdapter.isEnabled();
}
最后一行,
返回bluetoothAdapter.isEnabled(),触发squid:S2259(在SonarQube 5.6.4 LTS中)

可能会引发NullPointerException,因为此处的“bluetoothAdapter”可为Null

事实并非如此
bluetoothAdapter
在这里不可为null,因为Apache commons
Validate.notNull()
将在这种情况下引发异常

这是一个已知问题吗?它会被修复吗?

更新:

根据请求,完整的源代码(在同一文件中):


您使用的java analyzer的版本是什么?我似乎无法再重现这个问题。不知道发生了什么变化。版本:4.3.0.7717。是否有人可以确认最近(在java analyzer中)已经修复了此问题?从发行说明中可以看出,不应修复此问题,我希望会提出此问题。我会调查原因的,有什么消息吗?我再也看不到了,所以可能是IntelliJ中的SonarLint插件出现了同步问题。您使用的java analyzer的版本是什么?我似乎再也无法重现这个问题了。不知道发生了什么变化。版本:4.3.0.7717。是否有人可以确认最近(在java analyzer中)已经修复了此问题?从发行说明中可以看出,不应修复此问题,我希望会提出此问题。我会调查原因的,有什么消息吗?我再也看不到它了,所以它可能是IntelliJ中SonarLint插件的同步问题。
private BluetoothAdapter getBluetoothAdapter() {
    final BluetoothManager bluetoothManager = getBluetoothManager();
    Validate.notNull(bluetoothManager);
    return bluetoothManager.getAdapter();
}

BluetoothManager getBluetoothManager() {
    return (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
}