Changeset 16462 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-05-19T06:36:12+02:00 (5 years ago)
Author:
GerdP
Message:

fix #19259: NPE at org.openstreetmap.josm.tools.ReflectionUtils.findCaller()
revert changes from r16436

File:
1 edited

Legend:

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

    r16436 r16462  
    77import java.util.Collection;
    88import java.util.function.Function;
    9 import java.util.stream.IntStream;
    109
    1110import org.openstreetmap.josm.plugins.PluginHandler;
     
    6463    private static <T extends Object> T findCaller(Function<StackTraceElement, T> getter, Collection<T> exclusions) {
    6564        StackTraceElement[] stack = Thread.currentThread().getStackTrace();
    66         return IntStream.range(3, stack.length)
    67                 .mapToObj(i -> getter.apply(stack[i]))
    68                 .filter(t -> exclusions == null || !exclusions.contains(t))
    69                 .findFirst().orElse(null);
     65        for (int i = 3; i < stack.length; i++) {
     66            T t = getter.apply(stack[i]);
     67            if (exclusions == null || !exclusions.contains(t)) {
     68                return t;
     69            }
     70        }
     71        return null;
    7072    }
    7173}
Note: See TracChangeset for help on using the changeset viewer.