matthiasblaesing commented on code in PR #5797:
URL: https://github.com/apache/netbeans/pull/5797#discussion_r1162039142


##########
java/java.navigation/src/org/netbeans/modules/java/navigation/ElementNode.java:
##########
@@ -673,7 +673,12 @@ int alphaCompare( Description d1, Description d2 ) {
                 if (d1.posInKind != d2.posInKind) {
                     return d1.posInKind - d2.posInKind;
                 }
-                return d1.name.compareTo(d2.name);
+                int compareToName = d1.name.compareTo(d2.name);
+                if (compareToName == 0) {
+                    return d1.htmlHeader.compareTo(d2.htmlHeader);

Review Comment:
   If I read the code correctly, `htmlHeader` of `Description` can be `null` - 
at least one place explicitly checks for it:
   
   
https://github.com/apache/netbeans/blob/58c281ff2b9d06bfc9cb3204d99895c8b4b7979f/java/java.navigation/src/org/netbeans/modules/java/navigation/ElementNode.java#L302-L305
   
   Without having done a deep analysis, this looks as if `htmlHeader` might 
stay uninitialized here:
   
   
https://github.com/apache/netbeans/blob/58c281ff2b9d06bfc9cb3204d99895c8b4b7979f/java/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java#L357-L370
   
   I suggest this:
   
   ```suggestion
                       String htmlHeader1 = d1.htmlHeader != null ? 
d1.htmlHeader : "";
                       String htmlHeader2 = d2.htmlHeader != null ? 
d2.htmlHeader : "";
                       return htmlHeader1.compareTo(htmlHeader2);
   ```
   
   I expect only minimal impact by the `null` check.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to