You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Location class may be instantiated without an associated file. This causes fileUri to be null. Due to this Location::compareTo causes a NullPointerException, when used by a Location without an associated file
Reproducible
always
Steps to reproduce
Describe the steps needed to reproduce the issue.
Create a Location without an associated fileUri (Location.UNDEFINED / any constructor values with fileUri set to null)
Create a second Location object
call compareTo on the first Location comparing it to the second
Expected to sort by their Position objects. Actually throws NullPointerException.
The issue actually does not concern Location but instead IssueDialog where sorting is done without checking for these NullPointerExceptions. May also be an edge case of Java documentation for Array.sort, which can't take Comparators that don't accept null values
The issue is reasonably easy to fix and I believe I found a somewhat elegant solution to this.
The proposed solution adds explicit nullsLast comparators that check for null values of fileUri and position fields in Location before using the respective natural order of these fields in Location#compareTo(Location)
BookWood7th
changed the title
IssueDialog with PositionedStrings with undefined Locations
Location#compareTo(Location) breaks with undefined Location
Oct 23, 2024
Description
The Location class may be instantiated without an associated file. This causes fileUri to be null. Due to this Location::compareTo causes a NullPointerException, when used by a Location without an associated file
Reproducible
always
Steps to reproduce
Expected to sort by their Position objects. Actually throws NullPointerException.
Additional information
8e28439
The text was updated successfully, but these errors were encountered: