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

AccessEvent missing null check for RequestUrl #13

Open
aschepp opened this issue Apr 30, 2024 · 4 comments
Open

AccessEvent missing null check for RequestUrl #13

aschepp opened this issue Apr 30, 2024 · 4 comments

Comments

@aschepp
Copy link

aschepp commented Apr 30, 2024

I have the issue that requestUrl is logged as "null null null". This is because AccessEvent is missing a null check that exists in all methods except getRequestUrl.

public String getRequestURL() {
        if (requestURL == null) { // <- this has to be added.
            if (httpRequest != null) {
                StringBuilder buf = new StringBuilder();
                buf.append(httpRequest.getMethod());
                buf.append(AccessConverter.SPACE_CHAR);
                buf.append(httpRequest.getRequestURI());
                buf.append(getQueryString());
                buf.append(AccessConverter.SPACE_CHAR);
                buf.append(httpRequest.getProtocol());
                requestURL = buf.toString();
            } else {
                requestURL = NA;
            }
        }
        return requestURL;
    }

@ceki
Copy link
Member

ceki commented May 10, 2024

@aschepp Which servlet container are you using? Which version of logback-access?

The check is indeed missing. However, the null values might not be due to the missing check.

@aschepp
Copy link
Author

aschepp commented May 11, 2024

I'm using

  • Tomcat 10.1.23
  • slf4j 2.0.13
  • logback 1.5.6
  • logback-access based on git version from 2024-04-29 (as a custom build to fix this issue)
  • tomcat-slf4j-logback based on a recent git
  • logstash-logback-encoder based on a recent git

@aschepp
Copy link
Author

aschepp commented May 11, 2024

Before using the git version, I used version 2.0.1 of logback-access.

@aschepp
Copy link
Author

aschepp commented May 11, 2024

The reason why I am saying, that the null check is important, is that the method prepareForDeferredProcessing does call getRequestUrl, but it's useless, because it's overwritten the next time getRequestUrl is called, because the null check is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants