/** * report cause of interruption and record it to the build, if available. * * @since 1.425 */ public void recordCauseOfInterruption(Run<?,?> build, TaskListener listener) { List<CauseOfInterruption> r; // atomically get&clear causes. lock.writeLock().lock(); try { if (causes.isEmpty()) return; r = new ArrayList<CauseOfInterruption>(causes); causes.clear(); } finally { lock.writeLock().unlock(); } build.addAction(new InterruptedBuildAction(r)); for (CauseOfInterruption c : r) c.print(listener); }
/** * Report a line to the listener about this cause. */ public void print(TaskListener listener) { listener.getLogger().println(getShortDescription()); }
/** * report cause of interruption and record it to the build, if available. * * @since 1.425 */ public void recordCauseOfInterruption(Run<?,?> build, TaskListener listener) { List<CauseOfInterruption> r; // atomically get&clear causes. lock.writeLock().lock(); try { if (causes.isEmpty()) return; r = new ArrayList<CauseOfInterruption>(causes); causes.clear(); } finally { lock.writeLock().unlock(); } build.addAction(new InterruptedBuildAction(r)); for (CauseOfInterruption c : r) c.print(listener); }
/** * Report a line to the listener about this cause. */ public void print(TaskListener listener) { listener.getLogger().println(getShortDescription()); }
/** * If a build catches this exception, it should use this method to report it. * @param run * @param listener */ public void handle(Run<?,?> run, TaskListener listener) { Set<CauseOfInterruption> boundCauses = new HashSet<>(); for (InterruptedBuildAction a : run.getActions(InterruptedBuildAction.class)) { boundCauses.addAll(a.getCauses()); } Collection<CauseOfInterruption> diff = Sets.difference(new LinkedHashSet<>(causes), boundCauses); if (!diff.isEmpty()) { run.addAction(new InterruptedBuildAction(diff)); for (CauseOfInterruption cause : diff) { cause.print(listener); } } print(getCause(), listener); for (Throwable t : getSuppressed()) { print(t, listener); } } private static void print(@CheckForNull Throwable t, @Nonnull TaskListener listener) {
/** * If a build catches this exception, it should use this method to report it. * @param run * @param listener */ public void handle(Run<?,?> run, TaskListener listener) { Set<CauseOfInterruption> boundCauses = new HashSet<>(); for (InterruptedBuildAction a : run.getActions(InterruptedBuildAction.class)) { boundCauses.addAll(a.getCauses()); } Collection<CauseOfInterruption> diff = Sets.difference(new LinkedHashSet<>(causes), boundCauses); if (!diff.isEmpty()) { run.addAction(new InterruptedBuildAction(diff)); for (CauseOfInterruption cause : diff) { cause.print(listener); } } print(getCause(), listener); for (Throwable t : getSuppressed()) { print(t, listener); } } private static void print(@CheckForNull Throwable t, @Nonnull TaskListener listener) {