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

Fix logback optimization, when appender encoder with charset #313

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

altro3
Copy link
Contributor

@altro3 altro3 commented Aug 20, 2024

Fixed #311

@altro3
Copy link
Contributor Author

altro3 commented Aug 20, 2024

@melix Hi! Could you merge all Pr's and finilize new release? Without this fix can't use logback optimizer

Method valueOf = parameterType.getDeclaredMethod("valueOf", String.class);
codeBuilder.addStatement("$L.$L($T.valueOf($S))", parentVarName, method.getName(), ClassName.get(parameterType), model.getBodyText());
if (Charset.class.equals(parameterType)) {
parameterType.getDeclaredMethod("forName", String.class);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
parameterType.getDeclaredMethod("forName", String.class);

Not necessary since the type is fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yawkat As you see, you're not right. My first fix was right. LogLevel uses valueOf method, forName needs only for Charset

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you told me about this line parameterType.getDeclaredMethod("forName", String.class); - you're not right too. You need to set argument type - String.class, otherwise you will see exception message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yawkat For a long time I could not understand what you meant. Only now everything became clear. So, I just don't see the code that you see.

Look at the screenshot with the changes

изображение

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yawkat Also, if you are talking about calling a method, then I think that this would be done to get an exception at the optimization stage, i.e. the exception is thrown in the optimizer code. Otherwise, the code will be generated and you will receive an error only at the compilation stage and it will be much more difficult to understand where the error is. So I left the call to this method

@altro3 altro3 force-pushed the fix-logback-appender-charset branch 3 times, most recently from ed40f5b to 38bfc80 Compare August 20, 2024 09:34
@altro3 altro3 force-pushed the fix-logback-appender-charset branch from 38bfc80 to 2f1e7d0 Compare August 20, 2024 09:42
@altro3 altro3 requested a review from yawkat August 20, 2024 10:10
@sdelamo sdelamo requested a review from melix August 21, 2024 10:33
@melix melix merged commit 003fa50 into micronaut-projects:2.5.x Aug 21, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Json Formatter in logback.xml breaks Micronaut building
3 participants