Skip to content

Conversation

@kazuki43zoo
Copy link
Member

I've polished some codes.

  • Removed unnecessary + operation
  • Added isDebugEnabled
  • Renamed local variable

Please review.

Thanks.

log.debug(String.format("No %s found.", MapperFactoryBean.class.getName()));
if (log.isDebugEnabled()) {
log.debug(String.format("No %s found.", MapperFactoryBean.class.getName()));
}
Copy link
Member

Choose a reason for hiding this comment

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

@kazuki43zoo I don't really see any savings in this specific one. I understand the prior want to check for debug since there is an otherwise expensive looping on logging. However, that isn't the case here. I don't think this is going to amount to much in savings. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @hazendaz , thanks for your comment.

In this case, your understanding and opinion is correct.
However, i think general coding style to use the isDebugEnable method when debug message is dynamically.

What do you think ?

Copy link
Member

Choose a reason for hiding this comment

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

I would agree if the logging hit was needed and generally I see string format in a logger as bad practice. After looking at the class a bit, I see an obvious flaw in logging being used. It's using apache commons logging (legacy) but also has slf4j available. If we switched this to use slf4j instead, the cost can be incurred inside the debug statement rather than external to it. However, that is beyond this pull request so for the time being this is ok. I'm merging it now. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for merging !!
I agree with your opinion 👍

@hazendaz hazendaz merged commit 2e5fd33 into mybatis:master Apr 23, 2016
@kazuki43zoo kazuki43zoo deleted the polishing branch April 23, 2016 02:48
@kazuki43zoo kazuki43zoo added this to the 1.2.0 milestone Oct 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants