How to tell IDEA/Studio that the null check has been done?

后端 未结 6 1921
我在风中等你
我在风中等你 2020-12-06 06:14

I\'m developing with Android Studio/IntelliJ IDEA.

I have enabled the inspection check called "Constant conditions & exceptions" that shows a warning if

6条回答
  •  离开以前
    2020-12-06 06:54

    You could use //noinspection ConstantConditions that will remove the NPE warning for the following line, like this:

    String encoding = contentEncoding == null ? null : contentEncoding.getValue();
    
    //noinspection ConstantConditions
    if (!TextUtils.isEmpty(encoding) && encoding.equalsIgnoreCase("gzip")) {
        inputStream = new GZIPInputStream(entity.getContent());
    } else {
        inputStream = entity.getContent();
    }
    

提交回复
热议问题