Changeset 17855 in josm


Ignore:
Timestamp:
2021-05-02T10:05:54+02:00 (3 years ago)
Author:
simon04
Message:

see #20824 - Fix NPE found by Coverity Scan

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/notes/Note.java

    r17837 r17855  
    1111
    1212import org.openstreetmap.josm.data.coor.LatLon;
     13
     14import javax.annotation.Nullable;
    1315
    1416/**
     
    159161     * @since 11821
    160162     */
     163    @Nullable
    161164    public NoteComment getLastComment() {
    162165        return comments.isEmpty() ? null : comments.get(comments.size()-1);
     
    175178     * @return First comment object
    176179     */
     180    @Nullable
    177181    public NoteComment getFirstComment() {
    178182        return comments.isEmpty() ? null : comments.get(0);
    179183    }
    180184
     185    @Nullable
    181186    private String getUserName() {
    182187        return getFirstComment() == null ? null : getFirstComment().getUser().getName();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

    r17768 r17855  
    248248        }
    249249        return Pattern.compile("\\s+").splitAsStream(filter).allMatch(string -> {
     250            NoteComment lastComment = note.getLastComment();
    250251            switch (string) {
    251252                case "open":
     
    254255                    return note.getState() == State.CLOSED;
    255256                case "reopened":
    256                     return note.getLastComment().getNoteAction() == NoteComment.Action.REOPENED;
     257                    return lastComment != null && lastComment.getNoteAction() == NoteComment.Action.REOPENED;
    257258                case "new":
    258259                    return note.getId() < 0;
    259260                case "modified":
    260                     return note.getLastComment().isNew();
     261                    return lastComment != null && lastComment.isNew();
    261262                default:
    262263                    return note.getComments().toString().contains(string);
Note: See TracChangeset for help on using the changeset viewer.