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

error when servlet-mapping contains 'log' #2

Closed
artellan opened this Issue Feb 8, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@artellan

artellan commented Feb 8, 2013

When the TrackerServlet is mapped to a URL Pattern containing the string '/log', such as /log4j/*, it causes problems with some of the servlet code. For example, the /config page produces a NullPointerException:

java.lang.NullPointerException
        at log4jwebtracker.servlet.TrackerServlet.doHTML(TrackerServlet.java:364)
        at log4jwebtracker.servlet.TrackerServlet.doConfiguration(TrackerServlet.java:157)
        at log4jwebtracker.servlet.TrackerServlet.doPage(TrackerServlet.java:114)
        at log4jwebtracker.servlet.TrackerServlet.service(TrackerServlet.java:89)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)

The problem is that the "action" variable is set using request.getRequestURI(), which contains the url pattern for the servlet. So you can see that line 357 of TrackerServlet, which would normally evaluate to false for a /config request, evaluates to true if the url pattern contains '/log'.

if (request.getAttribute("action").toString().indexOf("/log") != -1) {

This causes problems, as it's not supposed to be doing the /log stuff when it's in /config mode! In particular, the above NullPointerException occurs because there is no fileAppenders request attirbute in Config mode.

This could be fixed simply in the documentation -- specifying which substrings are not acceptable in serlvet-mapping url-pattern (/log, /config, etc.). Or the code could be fixed also at some point.
(thanks for a great tool!!)

@mrsarm

This comment has been minimized.

Show comment
Hide comment
@mrsarm

mrsarm Feb 19, 2013

Owner

Hello @artellan, thanks for the bug report, sorry for the late, I was in vacations.

You are right about the error, for now I don't have time to take make the correction. A best way to check the URL will be a pattern comparison, but only using Java 1.4 SE API.

If you have a patch, please fork the project with the correction, and I will be test and merge if the fix is correct.

Owner

mrsarm commented Feb 19, 2013

Hello @artellan, thanks for the bug report, sorry for the late, I was in vacations.

You are right about the error, for now I don't have time to take make the correction. A best way to check the URL will be a pattern comparison, but only using Java 1.4 SE API.

If you have a patch, please fork the project with the correction, and I will be test and merge if the fix is correct.

mrsarm added a commit that referenced this issue Jun 14, 2014

@mrsarm

This comment has been minimized.

Show comment
Hide comment
@mrsarm

mrsarm Jun 22, 2014

Owner

I fixed the issue without need to make a pattern comparison, just using request.getPathInfo(), but now I have doubt about the patch works in no Tomcat webservers...

Owner

mrsarm commented Jun 22, 2014

I fixed the issue without need to make a pattern comparison, just using request.getPathInfo(), but now I have doubt about the patch works in no Tomcat webservers...

@mrsarm mrsarm closed this Jun 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment