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

SLING-12297 log a warning in case no servlet was found #41

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

joerghoh
Copy link
Contributor

No description provided.

@joerghoh joerghoh merged commit 2bd31bf into master Apr 17, 2024
1 check was pending
@@ -517,6 +518,11 @@ public static void service(SlingHttpServletRequest request,
Servlet servlet = requestData.getContentData().getServlet();
if (servlet == null) {

log.warn("Did not find a servlet to handle the request (path=%s,selectors=%,extension=%s,suffix=%s)",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple things:

  1. Shouldn't these just be positional parameters ({}) in logs, not String.format-style parameters?
  2. Not sure if needed here, but if you use a logger method that ends up var-args (more than 2 format arguments/exception), it is often good to wrap with if (Logger.isXxxEnabled()) { ... } to avoid the varargs array creation.

For (2) it really depends on how frequently it is expected to occur. This one might be ok, but I figured better to mention it.

Copy link
Contributor Author

@joerghoh joerghoh Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect that this code path is taken very frequently, as it's in a error path, which results in a 404.

But are so right about (1)

Fix in #42

@joerghoh joerghoh deleted the SLING-12297-logging-for-null-servlet branch May 17, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants