alibaba / alibaba/p3c

自动拆箱有可能产生NPE 提示 bug

Open
#753 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
30.8k
Forks
8k
PR merge metrics
No merged PRs in 30d

Description

## Rule content

返回类型为基本数据类型【long】,return包装数据类型的对象【Long】时,自动拆箱有可能产生NPE

## Problem description

IntelliJ IDEA 2020.2.1 (Ultimate Edition) Build #IU-202.6948.69, built on August 25, 2020
Alibaba Java Coding Guidelines Plugin Version: 2.1.0

![2020_9_3 14_47_38](https://user-images.githubusercontent.com/58985624/92080988-fa939300-edf4-11ea-8899-0132ee306abb.png)

`return` 之前已经做了非空校验,为何还会提示 NPE 警告?

## Advice

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the warning with IntelliJ IDEA 2020.2.1 and Alibaba Java Coding Guidelines Plugin 2.1.0, using a method that returns long, returns a Long, and performs a non-null check first. Trace the rule that reports the possible NPE and verify that the warning is no longer produced when the check makes unboxing safe.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.