Ignore:
Timestamp:
2016-08-24T00:18:37+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13434 - Increase bug report test coverage (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

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

    r10819 r10886  
    55import java.util.ArrayList;
    66import java.util.LinkedList;
     7import java.util.concurrent.CopyOnWriteArrayList;
    78import java.util.function.BiFunction;
     9import java.util.function.Predicate;
    810
    911import org.openstreetmap.josm.Main;
     
    2325    private Thread displayThread;
    2426    private final BiFunction<ReportedException, Integer, SuppressionMode> bugReportHandler = getBestHandler();
     27    private final CopyOnWriteArrayList<Predicate<ReportedException>> handlers = new CopyOnWriteArrayList<>();
    2528    private int displayedErrors;
    2629
     
    97100
    98101    private SuppressionMode displayFor(ReportedException e) {
     102        if (handlers.stream().anyMatch(p -> p.test(e))) {
     103            Main.trace("Intercepted by handler.");
     104            return SuppressionMode.NONE;
     105        }
    99106        return bugReportHandler.apply(e, getDisplayedErrors());
    100107    }
     
    123130    }
    124131
     132    /**
     133     * Allows you to peek or even intersect the bug reports.
     134     * @param handler The handler. It can return false to stop all further handling of the exception.
     135     * @since 10886
     136     */
     137    public void addBugReportHandler(Predicate<ReportedException> handler) {
     138        handlers.add(handler);
     139    }
     140
     141    /**
     142     * Gets the global bug report queue
     143     * @return The queue
     144     * @since 10886
     145     */
    125146    public static BugReportQueue getInstance() {
    126147        return INSTANCE;
Note: See TracChangeset for help on using the changeset viewer.