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

Use varargs for log parameters instead of new Object[] #303

Closed
wants to merge 6 commits into from

Conversation

FSchumacher
Copy link

Some log statements where called with a combination of new Object[] {...} and
an exception. That lead to a misinterpretation of those parameters. The first
object array is considered to be the first argument and the exception the second
parameter of the format string.
It should have been interpreted as the members of the object array as the parameters
for the format string and the exception as the exception itself.

So for example:

  LOG.info("User {} has done {}", new Object[] {"A", "something"}, e);

would log something like:

  User [A, something] has done java.lang.RuntimeException: OOps

@jbonofre jbonofre self-requested a review November 18, 2019 04:46
Some log statements where called with a combination of `new Object[] {...}` and
an exception. That lead to a misinterpretation of those parameters. The first
object array is considered to be the first argument and the exception the second
parameter of the format string.
It should have been interpreted as the members of the object array as the parameters
for the format string and the exception as the exception itself.

So for example:

  LOG.info("User {} has done {}", new Object[] {"A", "something"}, e);

would log something like:

  User [A, something] has done java.lang.RuntimeException: OOps
…param

The first log format string in this commit has more placeholder than parameters.
I added one that I think is the correct one, but please check before committing this one.
…cue exception

This was again a case, where the object array would put the exception parameter
into a place where it would be taken as the second parameter and not used as intended.
@jbonofre
Copy link
Member

Superseeded by PR #631

@jbonofre jbonofre closed this Mar 20, 2021
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.

2 participants