diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index f3571bb8c71929097b25f4d697c852ac07c459b1..bcdc69f7f35e5e720e586f22055bb0362f637d7a 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -152,6 +152,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import hudson.util.RunList; import java.util.concurrent.atomic.AtomicLong; +import javax.annotation.CheckForNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -1392,7 +1393,17 @@ public class Functions { return value!=null ? value : defaultValue; } - public static String printThrowable(Throwable t) { + /** + * Gets info about the specified {@link Throwable}. + * @param t Input {@link Throwable} + * @return If {@link Throwable} is not null, a summary info with the + * stacktrace will be returned. Otherwise, the method returns a default + * "No exception details" string. + */ + public static String printThrowable(@CheckForNull Throwable t) { + if (t == null) { + return Messages.Functions_NoExceptionDetails(); + } StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); return sw.toString(); diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index df9fb9714e2fac1d1946578f4f66216479e174cf..f4c85460ace5533adb0b1ae5f97b7d0be3635983 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -627,7 +627,7 @@ public class Executor extends Thread implements ModelObject { * @return null if the death is expected death or the thread {@link #isActive}. * @since 1.142 */ - public Throwable getCauseOfDeath() { + public @CheckForNull Throwable getCauseOfDeath() { return causeOfDeath; } diff --git a/core/src/main/resources/hudson/Messages.properties b/core/src/main/resources/hudson/Messages.properties index 2613298aff908330ce3b1b751a5832ef8c414d60..00360f9b23afb0b12f02a119b832552cf38098de 100644 --- a/core/src/main/resources/hudson/Messages.properties +++ b/core/src/main/resources/hudson/Messages.properties @@ -67,4 +67,6 @@ AboutJenkins.Description=See the version and license information. ProxyConfiguration.TestUrlRequired=Test URL is required. ProxyConfiguration.FailedToConnectViaProxy=Failed to connect to {0}. ProxyConfiguration.FailedToConnect=Failed to connect to {0} (code {1}). -ProxyConfiguration.Success=Success \ No newline at end of file +ProxyConfiguration.Success=Success + +Functions.NoExceptionDetails=No Exception details \ No newline at end of file