You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2002/08/28 02:30:20 UTC

DO NOT REPLY [Bug 12112] New: - CountingQuietWriter wrongly uses # of characters instead of real # of bytes

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12112>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12112

CountingQuietWriter wrongly uses # of characters instead of real # of bytes

           Summary: CountingQuietWriter wrongly uses # of characters instead
                    of real # of bytes
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Appender
        AssignedTo: log4j-dev@jakarta.apache.org
        ReportedBy: w.fukushima@pfu.fujitsu.com


LOG4J VERSION

1.2.6


BUG DESCRIPTION

org.apache.log4j.helpers.CountingQuietWriter says in its class comment:

  Counts the number of bytes written.

However, since its write(String) method counts it by String.length(),
current result becomes number of characters instead of byte-size.


IMPACT

CountingQuietWriter is used by RollingFileAppender to decide if rollOver()
should be called.
When multi-bytes text is written, the log file grows up over its maximum
file size specified by setMaxFileSize().


HOW TO FIX

<J2SE v 1.3.1 or earlier>
Impossible, because we cannot know which CharToByteConverter is used at all.
A better solution is to call String.getBytes().length instead of
String.length().
(still has a problem because it assumes that the text is encoded in default
 character encoding, which could be different.)

<J2SE v 1.4 or later>
Possible, if CountingQuietWriter can know which java.nio.charset.Charset
should be used. (I do not know how to get this information though.)

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>