Skip to content

Commit

Permalink
Merge pull request #1468 from synopsys-arc-oss/JENKINS-25734
Browse files Browse the repository at this point in the history
[JENKINS-25734] - Prevent NPE in Executor/causeOfDeath page on "expected thread death"
  • Loading branch information
oleg-nenashev committed Jun 13, 2015
2 parents 194fa56 + bf7f14b commit d5d8463
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 12 additions & 1 deletion core/src/main/java/hudson/Functions.java
Expand Up @@ -152,6 +152,7 @@
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;

Expand Down Expand Up @@ -1392,7 +1393,17 @@ public static <T> T defaulted(T value, T defaultValue) {
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
* &quot;No exception details&quot; 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();
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Executor.java
Expand Up @@ -627,7 +627,7 @@ public boolean isParking() {
* @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;
}

Expand Down
4 changes: 3 additions & 1 deletion core/src/main/resources/hudson/Messages.properties
Expand Up @@ -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
ProxyConfiguration.Success=Success

Functions.NoExceptionDetails=No Exception details

0 comments on commit d5d8463

Please sign in to comment.