Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some exception handling that was forgotten as part of JEP-227 #413

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/src/main/java/org/kohsuke/stapler/Stapler.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
*/
public class Stapler extends HttpServlet {

/**
* Exceptions we don't want to print a stacktrace for because they are normal behaviour.
* [JENKINS-4834] A stack trace is too noisy for this; could just need to log in.
*/
private static final Set<String> EXCEPTIONS_DO_NOT_PRINT_STACKTRACE = Set.of(
"org.acegisecurity.AccessDeniedException",
"org.springframework.security.access.AccessDeniedException"
);
private /*final*/ ServletContext context;

@SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "The Stapler class is not expected to be serialized.")
Expand Down Expand Up @@ -802,9 +810,7 @@ boolean tryInvoke(RequestImpl req, ResponseImpl rsp, Object node ) throws IOExce
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.)
} else if (EXCEPTIONS_DO_NOT_PRINT_STACKTRACE.contains(c.getName())) {
jglick marked this conversation as resolved.
Show resolved Hide resolved
getServletContext().log("While serving " + url + ": " + cause);
break;
}
Expand Down