redhat-developer / redhat-developer/vscode-java
Editor erroneously reports warning in conditional operator
未关闭
还没有人认领这个 Issue。
bug
diagnostics
upstream
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 547
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 issue 中的条件运算符示例复现该警告,并尽可能使用所列出的 Windows、JDK、VS Code 和 Java extension 版本。跟踪 Java extension 针对条件表达式的资源泄漏分析。完成的标准是:条件表达式不再产生错误警告,同时现有 if 语句的行为保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100