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

Jetty 12 - Re-enabled RequestLog tests. #8705

Merged
merged 2 commits into from
Oct 14, 2022

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Oct 12, 2022

Re-implemented features that were commented out.

Signed-off-by: Simone Bordet [email protected]

Re-implemented features that were commented out.

Signed-off-by: Simone Bordet <[email protected]>
Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

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

minor niggles.

@sbordet sbordet requested a review from joakime October 12, 2022 18:20
Signed-off-by: Simone Bordet <[email protected]>
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

Good that it is working now, but I'd like to see some more optimizations. I could be convinced to do those in a later PR... but perhaps we can do now?


long idleTO = _configuration.getIdleTimeout();
if (idleTO >= 0 && getIdleTimeout() != _oldIdleTimeout)
setIdleTimeout(_oldIdleTimeout);

if (getServer().getRequestLog() != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an instanceof for CustomRequestLog check?


long idleTO = _configuration.getIdleTimeout();
if (idleTO >= 0 && getIdleTimeout() != _oldIdleTimeout)
setIdleTimeout(_oldIdleTimeout);

if (getServer().getRequestLog() != null)
{
Authentication authentication = apiRequest.getAuthentication();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a TODO here for only adding the attributes if the custom request logger has these things in the format string? Better yet, in this PR, implement that check in the doStart method and have an EnumSet for if user name; real path; handlerName are needed, then only set the attributes if those booleans are set.


long idleTO = _configuration.getIdleTimeout();
if (idleTO >= 0 && getIdleTimeout() != _oldIdleTimeout)
setIdleTimeout(_oldIdleTimeout);

if (getServer().getRequestLog() != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto comments from ServletChannel

Comment on lines +325 to +327
public static final String HANDLER_NAME = CustomRequestLog.class.getName() + ".handlerName";
public static final String REAL_PATH = CustomRequestLog.class.getName() + ".realPath";
public static final String USER_NAME = CustomRequestLog.class.getName() + ".userPrincipal";
Copy link
Contributor

Choose a reason for hiding this comment

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

Make these an enum and then an EnumSet can be used to record which of them are required.

{
Authentication authentication = apiRequest.getAuthentication();
if (authentication instanceof Authentication.User userAuthentication)
_request.setAttribute(CustomRequestLog.USER_NAME, userAuthentication.getUserIdentity().getUserPrincipal().getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Ultimately, it might be best to have an EnumMap<CustomRequestLog.ATTR,String> as part of the request, as a more efficient way to pass these items for requests that don't use the attributes.

This probably needs to be tested... but if we do decide that just using attributes is best/simplest, then perhaps we give up on the whole lazy creation of the attributes map underneath as needless complexity.

i.e. either we continue to strive to avoid routine request attributes or we remove lazy request attribute map. It is silly to be lazy and routine.

@sbordet
Copy link
Contributor Author

sbordet commented Oct 14, 2022

@gregw your comments are too specific to a particular implementation of RequestLog, but we must be more generic.
I have recorded your concerns in #8715, so for now I'll merge this PR.

@sbordet sbordet merged commit a6f5e1f into jetty-12.0.x Oct 14, 2022
@sbordet sbordet deleted the jetty-12.0.x-reenable-customrequestlog branch October 14, 2022 08:30
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

Successfully merging this pull request may close these issues.

3 participants