Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread robert burrell donkin
On 11/18/06, robert burrell donkin <[EMAIL PROTECTED]> wrote: On 11/18/06, Joachim Draeger <[EMAIL PROTECTED]> wrote: > Am Samstag, den 18.11.2006, 08:53 + schrieb robert burrell donkin: > > > > Imho it is really interesting to see that in jdk 1.5 the string > > > concatenation is replaced by

Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread robert burrell donkin
On 11/18/06, Joachim Draeger <[EMAIL PROTECTED]> wrote: Am Samstag, den 18.11.2006, 08:53 + schrieb robert burrell donkin: > > Imho it is really interesting to see that in jdk 1.5 the string > > concatenation is replaced by StringBuilder by default and this way is > > even better than using

Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread Stefano Bagnara
Noel J. Bergman wrote: Stefano Bagnara wrote: I think we should wait to refactor this component until we'll switch to java 5 as the required jvm so we can introduce a Logger interface with the mixin's methods we need. Can you illustrate the pattern you have in mind for such a future approach

RE: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread Noel J. Bergman
Stefano Bagnara wrote: > I think we should wait to refactor this component until we'll switch to > java 5 as the required jvm so we can introduce a Logger interface with > the mixin's methods we need. Can you illustrate the pattern you have in mind for such a future approach? --- Noel

Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread Joachim Draeger
Am Samstag, den 18.11.2006, 08:53 + schrieb robert burrell donkin: > > Imho it is really interesting to see that in jdk 1.5 the string > > concatenation is replaced by StringBuilder by default and this way is > > even better than using the StringBuffer. > > perhaps one plan would be to factor

Re: Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread robert burrell donkin
On 11/18/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: I don't like this approach. most people don't like this approach the first time they see it: it feels wrong but give it time and think about it carefully before rushing to judgement I think we should wait to refactor this component unti

Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread Stefano Bagnara
I don't like this approach. I think we should wait to refactor this component until we'll switch to java 5 as the required jvm so we can introduce a Logger interface with the mixin's methods we need. If you want to avoid complex evaluation for debugging you will have to use the isEnabled

Re: a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread robert burrell donkin
On 11/18/06, robert burrell donkin <[EMAIL PROTECTED]> wrote: On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: > Bernd Fondermann wrote: > > On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: > >> > >> Output code 2 from jdk 1.4 > >> > String s2 = s + "test" + s1 + "test" + i; >

a logging solution [WAS Re: isLogEnabled() and StringBuffer]

2006-11-18 Thread robert burrell donkin
On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Bernd Fondermann wrote: > On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: >> >> Output code 2 from jdk 1.4 >> > String s2 = s + "test" + s1 + "test" + i; >> >> Output code 2 from jdk 1.5 >> > String s2 = (new StringBuilde

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Stefano Bagnara
Bernd Fondermann wrote: On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Output code 2 from jdk 1.4 > String s2 = s + "test" + s1 + "test" + i; Output code 2 from jdk 1.5 > String s2 = (new StringBuilder()).append(s).append("test") > .append(s1).append("test").append(i).t

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Vincenzo Gianferrari Pini
:-) Vincenzo Joachim Draeger wrote: Vincenzo Gianferrari Pini wrote: BTW: I have often seen NPE *bugs* in debug messages, that appeared magically when the costumer has turned on *de*bugging. :-) This could avoided by putting a try/catch block around... Im against this.. Even if the N

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Joachim Draeger
Vincenzo Gianferrari Pini wrote: BTW: I have often seen NPE *bugs* in debug messages, that appeared magically when the costumer has turned on *de*bugging. :-) This could avoided by putting a try/catch block around... Im against this.. Even if the NPE is in the debug message it should not

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Vincenzo Gianferrari Pini
Norman Maurer wrote: Joachim Draeger schrieb: ... BTW: I have often seen NPE *bugs* in debug messages, that appeared magically when the costumer has turned on *de*bugging. :-) This could avoided by putting a try/catch block around... Joachim Im against this.. Even if the N

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Norman Maurer
Joachim Draeger schrieb: > Hi Bernd, > > Am Freitag, den 17.11.2006, 08:42 +0100 schrieb Bernd Fondermann: > > >>> I also ran with jdk5 that code in a loop of 1 million iterations using >>> foo = "foo" and bar = "bar" (this is FAR from any realistic scenario). >>> >> Microbenchmarking, a

Re: isLogEnabled() and StringBuffer

2006-11-17 Thread Joachim Draeger
Hi Bernd, Am Freitag, den 17.11.2006, 08:42 +0100 schrieb Bernd Fondermann: > > I also ran with jdk5 that code in a loop of 1 million iterations using > > foo = "foo" and bar = "bar" (this is FAR from any realistic scenario). > > Microbenchmarking, again! ;-) > Could it be you are testing loop

Re: isLogEnabled() and StringBuffer

2006-11-16 Thread Bernd Fondermann
On 11/17/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Output code 2 from jdk 1.4 > String s2 = s + "test" + s1 + "test" + i; Output code 2 from jdk 1.5 > String s2 = (new StringBuilder()).append(s).append("test") > .append(s1).append("test").append(i).toString(); I also ran wi

RE: isLogEnabled() and StringBuffer

2006-11-16 Thread Noel J. Bergman
Stefano Bagnara wrote: > Input code 2: > String res = foo + "test" + bar + "test" + i; > Output code 2 from jdk 1.4 > String s2 = s + "test" + s1 + "test" + i; > Output code 2 from jdk 1.5 > String s2 = (new StringBuilder()).append(s).append("test") > .append(s1).append("test").append

Re: isLogEnabled() and StringBuffer

2006-11-16 Thread Stefano Bagnara
robert burrell donkin wrote: On 11/14/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Maybe this helps on this topic: http://wiki.java.net/bin/view/Javapedia/AlwaysUseStringBufferMisconception#Concatenating_Literal_Strings note that the misconception the link talks about is concatinating strin

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread robert burrell donkin
On 11/14/06, Joachim Draeger <[EMAIL PROTECTED]> wrote: Hi! Am I hitting another controversy topic? ;-) Example from ImapHandler.java catch ( IOException e ) { if ( getLogger().isErrorEnabled() ) { StringBuffer exceptionBuffer = new

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread robert burrell donkin
ommand > issue. > To make it clear: I'm not proposing refactoring all around James. I just > don't want to make extensive use of isLogEnabled() and StringBuffer(). > I'm going to remove it from Imap code where I think it brings more > readability. > > WDYT? A

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread robert burrell donkin
On 11/14/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Maybe this helps on this topic: http://wiki.java.net/bin/view/Javapedia/AlwaysUseStringBufferMisconception#Concatenating_Literal_Strings note that the misconception the link talks about is concatinating string literals, not variables use

RE: isLogEnabled() and StringBuffer

2006-11-14 Thread Noel J. Bergman
The path that you suggest is the exact opposite of a code review and code change that we deliberately undertook after performance testing. isEnabled should be used before formatting the message, and StringBuffers is more efficient than String concatentation at very little cost. We can review to se

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread Bernd Fondermann
:-) thanks, interesting read. although I must admit that my memory/GC statement indeed was a bit sloppy and is not covered here, AFAICS. Bernd On 11/14/06, Stefano Bagnara <[EMAIL PROTECTED]> wrote: Maybe this helps on this topic: http://wiki.java.net/bin/view/Javapedia/AlwaysUseStringBufferM

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread Stefano Bagnara
Maybe this helps on this topic: http://wiki.java.net/bin/view/Javapedia/AlwaysUseStringBufferMisconception#Concatenating_Literal_Strings Stefano Danny Angus wrote: On 11/14/06, Bernd Fondermann <[EMAIL PROTECTED]> wrote: On 11/14/06, Joachim Draeger <[EMAIL PROTECTED]> wrote: Memory garbage

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread Danny Angus
On 11/14/06, Bernd Fondermann <[EMAIL PROTECTED]> wrote: On 11/14/06, Joachim Draeger <[EMAIL PROTECTED]> wrote: Memory garbage should not be a problem any longer in the light of generational GCs. I'm not sure how you arrive at this sweeping conclusion! Profligate use of memory is a problem

Re: isLogEnabled() and StringBuffer

2006-11-14 Thread Bernd Fondermann
ing really much concats. I would use isDebugEnabled() only inside a loop and not in a per command issue. To make it clear: I'm not proposing refactoring all around James. I just don't want to make extensive use of isLogEnabled() and StringBuffer(). I'm going to remove it from Imap code where

isLogEnabled() and StringBuffer

2006-11-13 Thread Joachim Draeger
er command issue. BTW: catch ( IOException e ) { getLogger().error( "Cannot open connection from " + remoteHost + " (" + remoteIP + "): " + e.getMessage() ); throw e; } To make it clear: I'm not proposing refactoring all around Jam