Skip to content

Fix Log4jFixedFormatter buffer length #1419

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

Merged
merged 4 commits into from
Aug 3, 2023

Conversation

ppkarwasz
Copy link
Contributor

This PR fixes #1418 .

The buffer length in Log4jFixedFormatter was computed base on the length of the pattern. Now it is the double of the real length of a formatted date (in the English locale).

At the same time this migrates the FastDateFormatter tests to JUnit 5.

@ppkarwasz ppkarwasz added this to the 2.20.1 milestone Jul 13, 2023
@ppkarwasz ppkarwasz merged commit 1c250b0 into apache:2.x Aug 3, 2023
Comment on lines +514 to +516
* Returns the length of the resulting formatted date and time strings.
*
* @return the length of the resulting formatted date and time strings
Copy link
Member

Choose a reason for hiding this comment

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

This description is not correct, otherwise we won't need to double the size of the buffer in InstantFormatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I should add "in the ROOT locale" (which is basically English, but less anglocentric).

Copy link
Member

@vy vy Aug 3, 2023

Choose a reason for hiding this comment

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

I will appreciate that. Maybe also a note on "if you want to determine the max. length independent of the used locale, you better multiply this number by 2".

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.

ArrayOutOfBoundsException in Log4jFixedFormatter
2 participants