[JENKINS-25734] - Prevent NPE in Executor/causeOfDeath page if the field is null

The change does not fix the issue, but it suppresses NPE at least.
This commit is contained in:
Oleg Nenashev committed 2015-06-07 16:05:35 +03:00
1 parent 4f54c8af33
commit bf7f14b165
3 files changed
+16 -3

No files matched your search

+12 -1
View File
@@ -151,6 +151,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;
@@ -1372,7 +1373,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();