Bug 9285

Summary: SyslogWriter 's bug for multibyte enviroment
Product: Log4j - Now in Jira Reporter: Mamoru Kadota <moto>
Component: OtherAssignee: log4j-dev <log4j-dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Sun   
OS: Solaris   

Description Mamoru Kadota 2002-05-21 13:32:01 UTC
Hi,

I'm using log4j package(Version is 1.2.1) in project.
As Happen, when I used SyslogAppender and SyslogWriter for syslogd.
Written word is unperfectly to syslogd's "messages" file.
This word is so short than I expect that.

I thought, it's a enviroment problem with unicode.
Because I use log4j on multibyte enviroment.
(Spec:Fujitsu Solalis SunBlade 1000)
Then, I read log4j package's sources. I detected un-appropiate codes.

Next code is referd for "SyslogWriter.java".

>  public
>  void write(String string) throws IOException {
>    DatagramPacket packet = new DatagramPacket(string.getBytes(),
>        string.length(), 
>        address, SYSLOG_PORT);
>
>    if(this.ds != null)
>      ds.send(packet);
>    
>  }

"DatagramPacket()" 's second parameter is "string.length()".
But I thought. This suitable code is "string.getBytes().length".
Comment 1 Ceki Gulcu 2002-05-24 11:48:00 UTC
Mr. Kadota,

You are absolutely right. The computation of the byte array length is wrong.
Just fixed in CVS. The fix will be available in log4j 1.2.3 when that is 
released. Thank you for the very professionnal bug report. 
--
Ceki
Comment 2 Mamoru Kadota 2002-05-24 15:30:09 UTC
Mr.Ceki,
I appreciate your quickly response.
Thank you.