EA-35287 - NPE: DocumentImpl.changedUpdate

This commit is contained in:
Alexey Kudravtsev
2012-04-12 13:48:52 +04:00
parent d7a83e5118
commit 98cd545828
2 changed files with 3 additions and 1 deletions
@@ -41,6 +41,7 @@ public interface PrioritizedDocumentListener extends DocumentListener {
}
private int getPriority(Object o) {
assert o != null;
if (o instanceof PrioritizedDocumentListener) return ((PrioritizedDocumentListener)o).getPriority();
return Integer.MAX_VALUE;
}
@@ -679,7 +679,8 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
private DocumentListener[] getCachedListeners() {
DocumentListener[] cachedListeners = myCachedDocumentListeners;
if (cachedListeners == null) {
DocumentListener[] listeners = myDocumentListeners.toArray(new DocumentListener[myDocumentListeners.size()]);
List<DocumentListener> copy = new ArrayList<DocumentListener>(myDocumentListeners);
DocumentListener[] listeners = copy.toArray(new DocumentListener[copy.size()]);
Arrays.sort(listeners, PrioritizedDocumentListener.COMPARATOR);
myCachedDocumentListeners = cachedListeners = listeners;
}