diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 9a70ecb163..ff6582ccac 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -39,8 +39,6 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; import java.io.Writer; -import java.io.StringWriter; -import java.io.PrintWriter; import java.io.OutputStreamWriter; import java.net.URI; import java.util.ArrayList; @@ -852,9 +850,7 @@ public final class FilePath implements Serializable { throw e; // the remote side completed successfully, so the error must be local } catch (ExecutionException x) { // report both errors - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - throw new IOException2(sw.toString(),x); + throw new IOException2(Functions.printThrowable(e),x); } catch (TimeoutException _) { // remote is hanging throw e; diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 52e7e342a6..ed567571af 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -234,9 +234,7 @@ public final class PluginManager extends AbstractModelObject { } public String getExceptionString() { - StringWriter sw = new StringWriter(); - cause.printStackTrace(new PrintWriter(sw)); - return sw.toString(); + return Functions.printThrowable(cause); } } } diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index fc77360e65..bedd305a86 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -788,17 +788,6 @@ public class Util { } } - /** - * Obtains the stack dump as a string. - * - * @since 1.222 - */ - public static String toString(Throwable t) { - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - return sw.toString(); - } - public static final SimpleDateFormat XS_DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // Note: RFC822 dates must not be localized! diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java index cdd7056c8e..b82f7e6a0e 100644 --- a/core/src/main/java/hudson/scm/SubversionSCM.java +++ b/core/src/main/java/hudson/scm/SubversionSCM.java @@ -8,6 +8,7 @@ import hudson.FilePath.FileCallable; import hudson.Launcher; import hudson.Util; import hudson.XmlFile; +import hudson.Functions; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.BuildListener; @@ -1244,16 +1245,13 @@ public class SubversionSCM extends SCM implements Serializable { } else ok(); } catch (SVNException e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - String message=""; message += "Unable to access "+Util.escape(url)+" : "+Util.escape( e.getErrorMessage().getFullMessage()); message += " (show details)"; - message += "
"; + message += ""; message += " (Maybe you need to enter credential?)"; message += ", B extends AbstractBuild } } catch (IOException e) { // somehow failed to read the contents of the log - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - buf.append("Failed to access build log\n\n").append(sw); + buf.append("Failed to access build log\n\n").append(Functions.printThrowable(e)); } msg.setText(buf.toString()); diff --git a/core/src/main/java/hudson/util/HudsonFailedToLoad.java b/core/src/main/java/hudson/util/HudsonFailedToLoad.java index a646c65209..3b777f4ef0 100644 --- a/core/src/main/java/hudson/util/HudsonFailedToLoad.java +++ b/core/src/main/java/hudson/util/HudsonFailedToLoad.java @@ -1,5 +1,7 @@ package hudson.util; +import hudson.Functions; + import java.io.PrintWriter; import java.io.StringWriter; @@ -19,8 +21,6 @@ public class HudsonFailedToLoad extends ErrorObject { } public String getStackTrace() { - StringWriter sw = new StringWriter(); - exception.printStackTrace(new PrintWriter(sw)); - return sw.toString(); + return Functions.printThrowable(exception); } } diff --git a/core/src/main/java/hudson/util/InsufficientPermissionDetected.java b/core/src/main/java/hudson/util/InsufficientPermissionDetected.java index cda8ff92c7..ae61650695 100644 --- a/core/src/main/java/hudson/util/InsufficientPermissionDetected.java +++ b/core/src/main/java/hudson/util/InsufficientPermissionDetected.java @@ -1,5 +1,7 @@ package hudson.util; +import hudson.Functions; + import java.io.StringWriter; import java.io.PrintWriter; @@ -20,8 +22,6 @@ public class InsufficientPermissionDetected extends ErrorObject { } public String getExceptionTrace() { - StringWriter sw = new StringWriter(); - exception.printStackTrace(new PrintWriter(sw)); - return sw.toString(); + return Functions.printThrowable(exception); } } diff --git a/core/src/main/java/hudson/util/NoTempDir.java b/core/src/main/java/hudson/util/NoTempDir.java index 91d6cc6795..135feecfc5 100644 --- a/core/src/main/java/hudson/util/NoTempDir.java +++ b/core/src/main/java/hudson/util/NoTempDir.java @@ -1,5 +1,7 @@ package hudson.util; +import hudson.Functions; + import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; @@ -21,9 +23,7 @@ public class NoTempDir extends ErrorObject { } public String getStackTrace() { - StringWriter sw = new StringWriter(); - exception.printStackTrace(new PrintWriter(sw)); - return sw.toString(); + return Functions.printThrowable(exception); } public String getTempDir() {