Changeset 13319 in josm


Ignore:
Timestamp:
2018-01-14T04:17:16+01:00 (7 years ago)
Author:
Don-vip
Message:

see #15767 - CopyOnWriteArrayList iterators do not support remove method. Use streams instead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r13316 r13319  
    1313import java.util.EnumSet;
    1414import java.util.HashMap;
    15 import java.util.Iterator;
    1615import java.util.List;
    1716import java.util.Map;
     
    415414        if ((newValue == null ^ oldValue == null)
    416415                || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) {
    417             Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator();
    418             while (it.hasNext()) {
    419                 WeakReference<ProjectionChangeListener> wr = it.next();
    420                 ProjectionChangeListener listener = wr.get();
    421                 if (listener == null) {
    422                     it.remove();
    423                     continue;
    424                 }
    425                 listener.projectionChanged(oldValue, newValue);
    426             }
     416            listeners.removeIf(x -> x.get() == null);
     417            listeners.forEach(x -> x.get().projectionChanged(oldValue, newValue));
    427418            if (newValue != null && oldBounds != null && main != null) {
    428419                main.restoreOldBounds(oldBounds);
Note: See TracChangeset for help on using the changeset viewer.