This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
This is somewhat related to issue #200712, but requests a different (and somewhat complementary) refactoring pattern. Assume you have the following code: foo.getBar().doSomething(); This can produce a NullPointerException if either the 'foo' instance or the 'getBar()' method's return value is null. I think NetBeans would benefit from having a refactoring pattern which will change this into a multi-line statement which checks for null, like: if (foo == null) { throw new NullPointerException("foo is null"); } Bar bar = foo.getBar(); if (bar == null) { throw new NullPointerException("bar is null"); } bar.doSomething(); This will be quite helpful for working with legacy code, especially when it has undocumented or inconsistent standards for null return values.