redhat-developer / redhat-developer/vscode-java

Editor erroneously reports warning in conditional operator

オープン
#821 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug diagnostics upstream
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

Erroneous warnings are reported in the editor in conditional operators.

Environment
  • Operating System: Windows 10 Pro
  • JDK version: OpenJDK 11.0.1
  • Visual Studio Code version: 1.30.1
  • Java extension version: 0.40.0
Steps To Reproduce

Write code like the following:

SpeedController motor;
if (RobotMap.isCompetitionRobot)
{
	motor = new WPI_TalonSRX(RobotMap.liftMotorCanDeviceId);
}
else
{
	motor = new Spark(RobotMap.centerLegMotorPwmChannel);
}
		
motor = RobotMap.isCompetitionRobot
	? new WPI_TalonSRX(RobotMap.liftMotorCanDeviceId)
	: new Spark(RobotMap.centerLegMotorPwmChannel);

where the class Spark extends a class that implements AutoCloseable.

Current Result

No warnings are reported in the if statement. However, the warning:

Resource leak: '<unassigned Closeable value>' is never closed

is reported for the code:

new Spark(RobotMap.centerLegMotorPwmChannel)

in the conditional operator.

Expected Result

No warnings should be reported at all.

Additional Informations

None.

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、issue にある条件演算子の例で警告を再現します。可能な場合は、記載されている Windows、JDK、VS Code、Java extension のバージョンを使用します。条件式に対する Java extension のリソースリーク解析を追跡します。条件式で誤った警告が生成されず、既存の if 文の動作が変更されないことをもって完了とします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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