At 10:23 PM 9/17/2004, Elias Ross wrote:

The java.io.Writer classes are synchronized internally.  There is a lock
internally, so the only reason to lock externally is to synchronize
state on another operation.  Say, if you do w.write(X); w.write(Y);

Agreed.

If you  look at the  way Layouts are  designed in 1.3, you  should see
that  layouts access  the output  stream  directly. Thus,  it is  100%
certain  that  the  internal  lock  in java.io.Writer  object  is  not
sufficient. The access pattern on the Writer, say w, will be
w.write(X1), w.write(X2), ..., w.write(Xn).

The fact that  WriterAppender does not let it's  layout write directly
to  the underlying  Writer  is  an commission.  It  will be  corrected
shortly.

If you want to write multiple times safely, you can lock the object
directly. Holding a lock on the appender while doing all writes is a
little heavy-handed.

Some would say heavy-handed, others would say simple and robust. Given the history of this discussion (see bug report 24159), I have a strong bias against modifying the existing synchronization code in AppenderSkeleton. The problem in 24159 is just too contrived to be taken seriously.

However,  I   really  welcome   this  discussion  because   it  raises
interesting questions,  but please do not expect me or any other log4j
developer  to  casually adopt  modifications  which  can have  serious
impact. It  is not  going happen because  someone thinks it's  cool or
that it would  solve some weird bug. It will happen  only after we can
certain that the  new code is correct, better,  and easy to understand
and to maintain.


-- Ceki G�lc�

For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to