ehsavoie commented on a change in pull request #1426: [NETBEANS-2980] Fix 
potential NPE on ImportAnalysis2.getPackage()
URL: https://github.com/apache/netbeans/pull/1426#discussion_r313833679
 
 

 ##########
 File path: 
java/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
 ##########
 @@ -390,7 +390,7 @@ private boolean checkPackagesForStarImport(String pkgName, 
CodeStyle cs) {
     }
 
     private PackageElement getPackageOf(Element el) {
-        while (el.getKind() != ElementKind.PACKAGE) el = 
el.getEnclosingElement();
+        while ((el != null) && (el.getKind() != ElementKind.PACKAGE)) el = 
el.getEnclosingElement();
 
 Review comment:
   More style than anything else but shouldn't a new variable and enclosing 
bracket makes the code more readable ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to