-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix logback optimization, when appender encoder with charset #313
Conversation
@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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameterType.getDeclaredMethod("forName", String.class); |
Not necessary since the type is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
ed40f5b
to
38bfc80
Compare
38bfc80
to
2f1e7d0
Compare
Fixed #311