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

PatternResolver fails to match all elements depending on order #11

Closed
paulmfarrar opened this issue Apr 17, 2019 · 2 comments
Closed

PatternResolver fails to match all elements depending on order #11

paulmfarrar opened this issue Apr 17, 2019 · 2 comments

Comments

@paulmfarrar
Copy link

I found an issue when re-ordering the elements in the log output pattern. If you change the logPattern in the server-config.yaml file to be "%m %D cs-uri" the example application crashes.

The issue appears to be caused by failing to resolve all the pattern elements in com.mdac.vertx.web.accesslogger.configuration.pattern.PatternResolver#resolvePattern. I've raised a pull request that adds a unit test and attempts to fix the issue by moving the offset check to only run if the extracted position is == to the previously found element.

I wasn't certain of the purpose of checking the offset, perhaps it can be ignored completely?

Happy to hear any comments.

Pull request: #10

@romanpierson
Copy link
Owner

Hi Paul

Good finding, very much appreciated. Indeed the offset check I added if I remember correct as you might have various elements starting with %{ and ending with }something and as the resolver does not eg takes in account opening and closing of those brackets you could get various candidates and then the one with the lowest offset should be the one you really want.

However it looks like I missed to add an equals here

else if (bestStart == -1 || (extractedPosition.getStart() <= bestStart && extractedPosition.getOffset() <**=** bestOffset)){

Your solution does the same so I just merged it back and version 1.3.1 is released.

@paulmfarrar
Copy link
Author

Hi Roman

The offset check makes sense now so I'm glad I kept it in. Thanks for the quick response in merging and releasing a new version.

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