github / github/codeql

Java: Nullness: LGTM.com - false positive

オープン
#3,176 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
false-positive Java
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

**Description of the false positive**

```java
if (!channel.isActive()) {
CompletableFuture currentFuture;
synchronized (channelPool) {
currentFuture = channelPool.get(offset);
if (currentFuture == finalFuture) { // final future is not null since it is used also before
channelPool.set(offset, null);
} else if (currentFuture == null) {
currentFuture = factory.apply(address); // <== assigned here
currentFuture.whenComplete(this::logConnection); // <== used here
channelPool.set(offset, currentFuture);
}
}

if (currentFuture == finalFuture) {
getChannel(address, messageType)
.whenComplete(
(recursiveResult, recursiveError) -> {
completeFuture(future, recursiveResult, recursiveError);
});
} else {
currentFuture.whenComplete( // <== can't be null here
```

We can see that if currentFuture is null then it is assigned a new value, which is used directly afterwards, which means it cant be null later.
**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/zeebe-io/zeebe/snapshot/e722021d676bdbeee3366fa1c10a915f031bbf0c/files/atomix/cluster/src/main/java/io/atomix/cluster/messaging/impl/ChannelPool.java?sort=name&dir=ASC&mode=heatmap#xa937c5d4af2d26c1:1

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。