Skip to content

Commit 22172a9

Browse files
authored
Merge pull request #8071 from junichi11/js-fix-npe
Prevent NPE
2 parents 70f6941 + 2a5566f commit 22172a9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/navigation/JsonOccurrencesFinder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public void setCaretPosition(int position) {
5959

6060
@Override
6161
public Map<OffsetRange, ColoringAttributes> getOccurrences() {
62-
return range2Attribs;
62+
return range2Attribs != null
63+
? Collections.unmodifiableMap(range2Attribs)
64+
: Collections.emptyMap();
6365
}
6466

6567
@Override

webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/navigation/OccurrencesFinderImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public void setCaretPosition(int position) {
5959

6060
@Override
6161
public Map<OffsetRange, ColoringAttributes> getOccurrences() {
62-
return range2Attribs;
62+
return range2Attribs != null
63+
? Collections.unmodifiableMap(range2Attribs)
64+
: Collections.emptyMap();
6365
}
6466

6567
@Override

0 commit comments

Comments
 (0)