Skip to content

Commit abb10ef

Browse files
Jörg Kubitziloveeclipse
authored andcommitted
fix concurrent use of AbstractTextSearchResult.fMatchEvent #992
Some search results where missing when the same object was concurrently passed to listeners. There is no point to reuse the instance. #992
1 parent 40a644f commit abb10ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
4444

4545
private final ConcurrentMap<Object, Set<Match>> fElementsToMatches;
4646
private final List<ISearchResultListener> fListeners;
47-
private final MatchEvent fMatchEvent;
4847
private final AtomicInteger matchCount;
4948

5049
private MatchFilter[] fMatchFilters;
@@ -55,7 +54,6 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
5554
protected AbstractTextSearchResult() {
5655
fElementsToMatches= new ConcurrentHashMap<>();
5756
fListeners= new ArrayList<>();
58-
fMatchEvent= new MatchEvent(this);
5957
matchCount = new AtomicInteger(0);
6058
fMatchFilters= null; // filtering disabled by default
6159
}
@@ -145,12 +143,14 @@ public void addMatches(Match[] matches) {
145143
}
146144

147145
private MatchEvent getSearchResultEvent(Match match, int eventKind) {
146+
MatchEvent fMatchEvent = new MatchEvent(this);
148147
fMatchEvent.setKind(eventKind);
149148
fMatchEvent.setMatch(match);
150149
return fMatchEvent;
151150
}
152151

153152
private MatchEvent getSearchResultEvent(Collection<Match> matches, int eventKind) {
153+
MatchEvent fMatchEvent = new MatchEvent(this);
154154
fMatchEvent.setKind(eventKind);
155155
Match[] matchArray= matches.toArray(new Match[matches.size()]);
156156
fMatchEvent.setMatches(matchArray);

0 commit comments

Comments
 (0)