Skip to content
Permalink
Browse files

[JENKINS-10524] Trying to suppress socket exceptions.

Committing optimistically since I do not know how to reproduce.
  • Loading branch information...
jglick committed Jul 25, 2013
1 parent 66c334e commit a6307f473e44aa4fd6a26275304d738dba5201c9
Showing with 26 additions and 4 deletions.
  1. +26 −4 core/src/main/java/org/kohsuke/stapler/Stapler.java
@@ -53,6 +53,7 @@
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
@@ -689,7 +690,9 @@ boolean tryInvoke(RequestImpl req, ResponseImpl rsp, Object node ) throws IOExce
}
} catch (IllegalAccessException e) {
// this should never really happen
getServletContext().log("Error while serving "+req.getRequestURL(),e);
if (!isSocketException(e)) {
getServletContext().log("Error while serving "+req.getRequestURL(),e);
}
throw new ServletException(e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
@@ -706,16 +709,22 @@ boolean tryInvoke(RequestImpl req, ResponseImpl rsp, Object node ) throws IOExce

StringBuffer url = req.getRequestURL();
if (cause instanceof IOException) {
getServletContext().log("Error while serving " + url, e);
if (!isSocketException(e)) {
getServletContext().log("Error while serving " + url, e);
}
throw (IOException) cause;
}
if (cause instanceof ServletException) {
getServletContext().log("Error while serving " + url, e);
if (!isSocketException(e)) {
getServletContext().log("Error while serving " + url, e);
}
throw (ServletException) cause;
}
for (Class<?> c = cause.getClass(); c != null; c = c.getSuperclass()) {
if (c == Object.class) {
getServletContext().log("Error while serving " + url, e);
if (!isSocketException(e)) {
getServletContext().log("Error while serving " + url, e);
}
} else if (c.getName().equals("org.acegisecurity.AccessDeniedException")) {
// [HUDSON-4834] A stack trace is too noisy for this; could just need to log in.
// (Could consider doing this for all AcegiSecurityException's.)
@@ -748,6 +757,19 @@ boolean tryInvoke(RequestImpl req, ResponseImpl rsp, Object node ) throws IOExce
return false;
}

private static boolean isSocketException(Throwable x) { // JENKINS-10524
if (x == null) {
return false;
}
if (x instanceof SocketException) {
return true;
}
if (String.valueOf(x.getMessage()).equals("Broken pipe")) { // TBD I18N
return true;
}
return isSocketException(x.getCause());
}

/**
* Try to dispatch the request against the given node, and if it fails, report an error to the client.
*/

0 comments on commit a6307f4

Please sign in to comment.
You can’t perform that action at this time.