Skip to content

Commit 2a5566f

Browse files
committed
Prevent NPE
- See the changes in GH-8028
1 parent c91a741 commit 2a5566f

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)