On 12/7/11 12:56 PM, Sanne Grinovero wrote:
On 7 December 2011 11:19, Bela Ban<bban(a)redhat.com> wrote:
> If you use a constant, this is not an issue, but what about:
>
> String constant="Error message bla bla";
> for(int i=1; i<=10; i++) {
> Â Â log.trace(constant + "-" + i);
> }
>
> ?
That should definitely be rewritten as
String constant="Error message bla bla";
if (log.isTraceEnabled()) {
final String constant="Error message bla bla";
for(int i=1; i<=10; i++) {
log.trace(constant + "-" + i);
}
}
No ! My example was meant to show a loop with *many* statements; one of
them being a log.trace() !
E.g.
for(......) {
...
log.trace();
...
}
--
Bela Ban
Lead JGroups (
http://www.jgroups.org)
JBoss / Red Hat