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

LOG4J2-3256: Reduce ignored package scope of KafkaAppender #640

Closed
wants to merge 2 commits into from

Conversation

dongjinleekr
Copy link

No description provided.

Copy link
Contributor

@remkop remkop left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

@dongjinleekr
Thank you for your PR.
This feels pretty brittle. What about putting this package list in a text file in the resource folder?
Note that this PR is for master but our current work is based on the branch release-2.x

@dongjinleekr
Copy link
Author

@garydgregory So, you mean...

  1. Make a list of kafka-clients packages in the resources directory.
  2. When KafkaAppender is initialized, load 1.
  3. Determine whether the given logging message should be ignored with 2.

Do I understand correctly?

@garydgregory
Copy link
Member

@garydgregory So, you mean...

  1. Make a list of kafka-clients packages in the resources directory.
  2. When KafkaAppender is initialized, load 1.
  3. Determine whether the given logging message should be ignored with 2.

Do I understand correctly?

@dongjinleekr
Exactly, my thought is to allow for a simpler way to manage this list.

@dongjinleekr
Copy link
Author

@garydgregory Great, with more maintainability! 👍

@dongjinleekr
Copy link
Author

Hi @garydgregory,

After some trial and error, I concluded that maintaining the ignored package list in an array would be better than a file-based approach. Here is why:

  • The effort to use an array is similar to a resource file.
  • The code becomes much concise and straightforward.
  • The array-based approach is much faster than the file-based one in initialization.

I also updated the PR to follow this way. How do you think? Is there any specific reason for the file-based approach?

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

An array works for me. See sort and bsearch comment, using the Arrays class.

@@ -136,6 +136,18 @@ public B setRetryCount(final String retryCount) {
return new Builder<B>().asBuilder();
}

private static final String[] KAFKA_CLIENT_PACKAGES = new String[] { "org.apache.kafka.common", "org.apache.kafka.clients" };
Copy link
Member

Choose a reason for hiding this comment

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

If you use a static init block, you can sort the array and then bsearch() it in the lookup method.

Copy link
Author

Choose a reason for hiding this comment

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

It seems like we are checking the package prefix, not the exact match. Is there any way to do prefix match with binary search? (Or, using regex would be better?)

Copy link
Member

Choose a reason for hiding this comment

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

You are correct, I forgot that this is just a prefix match, discard my last comment. I'll review in the morning unless someone else does first.

Copy link
Author

Choose a reason for hiding this comment

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

Great. Happy holidays!! 😄

asfgit pushed a commit that referenced this pull request Dec 26, 2021
Modified GitHub patch #640 from Lee
Dongjin/dongjinleekr/dongjin@apache.org.
asfgit pushed a commit that referenced this pull request Dec 26, 2021
Modified GitHub patch #640 from Lee
Dongjin/dongjinleekr/dongjin@apache.org.
asfgit pushed a commit that referenced this pull request Dec 26, 2021
Modified GitHub patch #640 from Lee
Dongjin/dongjinleekr/dongjin@apache.org.
@garydgregory
Copy link
Member

garydgregory commented Dec 26, 2021

@dongjinleekr

I modified GitHub patch #640 and pushed patches to branches release-2.x and master.

You are credited in changes.xml.

Thank you for your help!

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