Bug 40502 - SyslogAppender assumes all lines start with tab
SyslogAppender assumes all lines start with tab
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Appender
1.2
Other other
: P2 normal
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2006-09-13 20:07 UTC by Ian Reilly
Modified: 2007-02-21 15:40 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Reilly 2006-09-13 20:07:27 UTC
The SyslogAppender assumes each line of output starts with a tab and replaces 
it with spaces.  If the line doesn't start with a tab, the first character of 
the line is lost.  If the line is empty, the appender will get an exception.

The patch to fix this problem is:

*** SyslogAppender.java.orig	Wed Sep 13 15:53:09 2006
--- SyslogAppender.java	Wed Sep 13 15:53:05 2006
***************
*** 260,266 ****
          if(len > 0) {
            sqw.write(s[0]);
            for(int i = 1; i < len; i++) {
!             sqw.write(TAB+s[i].substring(1));
            }
          }
        }
--- 260,274 ----
          if(len > 0) {
            sqw.write(s[0]);
            for(int i = 1; i < len; i++) {
!             if (s[i].length() > 0) {
!               if (s[i].charAt(0) == '\t') {
!                 sqw.write(TAB+s[i].substring(1));
!               } else {
!                 sqw.write(TAB+s[i]);
!               }
!             } else {
!               sqw.write(s[i]);
!             }
            }
          }
        }
Comment 1 Kay Abendroth 2006-11-12 11:04:39 UTC
Do you have this problem in 1.2.14 also?
Comment 2 Curt Arnold 2007-02-21 15:40:31 UTC
Bug is in 1.2.14, SyslogAppenderTest.testBadTabbing will throw an exception without code fix.

Committed against 1.2 branch in rev 510307.

Corresponding code in trunk has been commented out earlier.