|
30 | 30 | import com.google.common.util.concurrent.SettableFuture; |
31 | 31 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
32 | 32 | import groovy.lang.Closure; |
33 | | -import hudson.Main; |
34 | 33 | import hudson.model.Descriptor; |
35 | 34 | import hudson.model.Result; |
36 | 35 | import hudson.util.DaemonThreadFactory; |
|
66 | 65 | import java.util.function.Function; |
67 | 66 | import java.util.logging.Level; |
68 | 67 | import java.util.logging.Logger; |
| 68 | +import java.util.stream.Stream; |
69 | 69 | import jenkins.model.CauseOfInterruption; |
70 | 70 | import jenkins.util.ContextResettingExecutorService; |
71 | 71 | import org.codehaus.groovy.runtime.InvokerInvocationException; |
@@ -328,39 +328,33 @@ private void completed(@NonNull Outcome newOutcome) { |
328 | 328 | whenOutcomeDelivered = new Throwable(); |
329 | 329 | } else { |
330 | 330 | Throwable failure = newOutcome.getAbnormal(); |
331 | | - Level level; |
332 | | - if (Main.isUnitTest) { |
333 | | - if (failure instanceof FlowInterruptedException && ((FlowInterruptedException) failure).getCauses().stream().anyMatch(BodyFailed.class::isInstance)) { |
334 | | - // Very common and generally uninteresting. |
335 | | - level = Level.FINE; |
336 | | - } else { |
337 | | - // Possibly a minor bug. |
338 | | - level = Level.INFO; |
339 | | - } |
340 | | - } else { |
341 | | - // Typically harmless; do not alarm users. |
342 | | - level = Level.FINE; |
343 | | - } |
344 | | - if (LOGGER.isLoggable(level)) { |
345 | | - LOGGER.log(level, "already completed " + this, new IllegalStateException("delivered here")); |
| 331 | + Throwable earlierFailure = outcome.getAbnormal(); |
| 332 | + if (LOGGER.isLoggable(Level.FINE)) { |
| 333 | + LOGGER.log(Level.FINE, "already completed " + this, new IllegalStateException("delivered here")); |
346 | 334 | if (failure != null) { |
347 | | - LOGGER.log(level, "new failure", failure); |
| 335 | + LOGGER.log(Level.FINE, "new failure", failure); |
348 | 336 | } else { |
349 | | - LOGGER.log(level, "new success: {0}", outcome.getNormal()); |
| 337 | + LOGGER.log(Level.FINE, "new success: {0}", outcome.getNormal()); |
350 | 338 | } |
351 | 339 | if (whenOutcomeDelivered != null) { |
352 | | - LOGGER.log(level, "previously delivered here", whenOutcomeDelivered); |
| 340 | + LOGGER.log(Level.FINE, "previously delivered here", whenOutcomeDelivered); |
353 | 341 | } |
354 | | - Throwable earlierFailure = outcome.getAbnormal(); |
355 | 342 | if (earlierFailure != null) { |
356 | | - LOGGER.log(level, "earlier failure", earlierFailure); |
| 343 | + LOGGER.log(Level.FINE, "earlier failure", earlierFailure); |
357 | 344 | } else { |
358 | | - LOGGER.log(level, "earlier success: {0}", outcome.getNormal()); |
| 345 | + LOGGER.log(Level.FINE, "earlier success: {0}", outcome.getNormal()); |
359 | 346 | } |
360 | 347 | } |
| 348 | + if (failure != null && earlierFailure != null && !refersTo(failure, earlierFailure)) { |
| 349 | + earlierFailure.addSuppressed(failure); |
| 350 | + } |
361 | 351 | } |
362 | 352 | } |
363 | 353 |
|
| 354 | + private static boolean refersTo(Throwable t1, Throwable t2) { |
| 355 | + return t1 == t2 || t1.getCause() != null && refersTo(t1.getCause(), t2) || Stream.of(t1.getSuppressed()).anyMatch(t3 -> refersTo(t3, t2)); |
| 356 | + } |
| 357 | + |
364 | 358 | /** |
365 | 359 | * When this step context has completed execution (successful or otherwise), plan the next action. |
366 | 360 | */ |
|
0 commit comments