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 2005/10/27 22:05:33 UTC

DO NOT REPLY [Bug 37282] New: - SyslogAppender leaks descriptors

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

http://issues.apache.org/bugzilla/show_bug.cgi?id=37282

           Summary: SyslogAppender leaks descriptors
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: iwreilly@yahoo.com


The attached patch for version 1.2.12 fixes two problems in 
org.apache.log4j.net.SyslogAppender.  First, it doesn't close the writer and as 
a result leaks UDP sockets.  Second, when logging an exception, it assumes that 
all lines after the first line start with a \t character.  If this is not the 
case, it removes the first character from the line (or throws an exception if 
the line is empty).

--- SyslogAppender.java.orig    2005-10-25 15:50:35.000000000 -0400
+++ SyslogAppender.java 2005-10-25 15:19:57.000000000 -0400
@@ -121,8 +121,11 @@
  public
  void close() {
    closed = true; 
-    // A SyslogWriter is UDP based and needs no opening. Hence, it
-    // can't be closed. We just unset the variables here.
+    try {
+       if (sqw != null) sqw.close();
+    } catch (Exception e) {
+       // ignore error
+    }
    sqw = null;
  }

@@ -260,7 +263,15 @@
        if(len > 0) {
          sqw.write(s[0]);
          for(int i = 1; i < len; i++) {
-            sqw.write (TAB+s[i].substring(1));
+            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]);
+            }
          }
        }
      }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org