1

I use facebook infer to detect error in my Android project. It find some error but is not error.

try {
        ...
        AppInfo app = JsonUtil.parseObject(resFileContent , AppInfo.class);
        app.setAppPackagePath(simpleInfoFile.getParent());
        return app;
} catch (Exception e) {
        e.printStackTrace();
        return null;
}

infer report the error

132: error: NULL_DEREFERENCE
  object app last assigned on line 130 could be null and is dereferenced at line 132
130.     AppInfo app = JsonUtil.parseObject(resFileContent , AppInfo.class);
131.
132. >                 app.setAppPackagePath(simpleInfoFile.getParent());
133.                   return app;
134.               } catch (Exception e) {
135.

The NullPointerException will be caught by try...catch... so it is not an error. How to tell infer not to report the error or ignore check in this line?

Zebulon Li
  • 540
  • 4
  • 21
  • 1
    Not sure if you've seen this: http://fbinfer.com/support.html How do I suppress Infer warnings on a class or method? In Java code, you can do this by annotating your class or method with @SuppressLint("infer"). Or @SuppressWarnings("infer") if your Infer is older than v0.10.0. – Joe Munoz Jul 17 '17 at 23:48

0 Answers0