Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta5
    • Fix Version/s: 2.0-beta7
    • Component/s: Appenders, Core
    • Labels:
      None

      Description

      On 2013/05/09, at 18:34, Tomek Kaczynski <tomek.kaczynski@gmail.com> wrote:

      Hi All,

      I'm using log4j2 since beta4, now beta5. In general it's a cute library, but there's some bug that I've found out recently :

      When a client code genreates a huge message ( 64k ), the underlying DatagramOutputStream fails ( UDP socket throws exception).

      After that all following flushes fail because data buffer is not cleared upon exception.

      So in lines

      DatagramOutputStream:91
      ----------------------------------------------------------------------
      public synchronized void flush() throws IOException {
      if (this.data != null && this.ds != null && this.address != null)

      { final DatagramPacket packet = new DatagramPacket(data, data.length, address, port); ds.send(packet); }

      data = null;
      }

      --------------------------------------------------------------------------

      data = null should be put in finally block or some simillar solution could be applied.

      What do you think ?

      Regards,
      Tomek

      Moreover DatagramOutputStream should check if message size is less then 64k .

        Issue Links

          Activity

          Hide
          Gary Gregory added a comment -

          I have refactored some TCP socket tests in order to test this issue. We now have an abstract test class with subclasses for TCP and UDP.

          The problem is that there are some odd errors in the new UDP tests that are @Ignore for now.

          From the debugger I see one log event properly marshaled and marshaled but for a second I get an exception.

          From Eclipse, running the test org.apache.logging.log4j.core.net.UDPSocketServerTest, I get:

          java.io.StreamCorruptedException: invalid stream header: 7372003E
          at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
          at java.io.ObjectInputStream.<init>(Unknown Source)
          at org.apache.logging.log4j.core.net.UDPSocketServer$DatagramPacketHandler.<init>(UDPSocketServer.java:167)
          at org.apache.logging.log4j.core.net.UDPSocketServer.run(UDPSocketServer.java:140)
          at java.lang.Thread.run(Unknown Source)
          Exception encountered on accept. Ignoring. Stack Trace :

          For these I am seeking help.

          See:

          commit -m "Testing LOG4J2-246: UDP socket Appender error. Needing help with UDPSocketServerTest, it is @Ignored for now." C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/TCPSocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServer.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/AbstractSocketServerTest.java
          Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/AbstractSocketServerTest.java
          Deleting C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java
          Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/TCPSocketServerTest.java
          Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServer.java
          Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServerTest.java
          Transmitting file data ...
          Committed revision 1480747.

          Show
          Gary Gregory added a comment - I have refactored some TCP socket tests in order to test this issue. We now have an abstract test class with subclasses for TCP and UDP. The problem is that there are some odd errors in the new UDP tests that are @Ignore for now. From the debugger I see one log event properly marshaled and marshaled but for a second I get an exception. From Eclipse, running the test org.apache.logging.log4j.core.net.UDPSocketServerTest, I get: java.io.StreamCorruptedException: invalid stream header: 7372003E at java.io.ObjectInputStream.readStreamHeader(Unknown Source) at java.io.ObjectInputStream.<init>(Unknown Source) at org.apache.logging.log4j.core.net.UDPSocketServer$DatagramPacketHandler.<init>(UDPSocketServer.java:167) at org.apache.logging.log4j.core.net.UDPSocketServer.run(UDPSocketServer.java:140) at java.lang.Thread.run(Unknown Source) Exception encountered on accept. Ignoring. Stack Trace : For these I am seeking help. See: commit -m "Testing LOG4J2-246 : UDP socket Appender error. Needing help with UDPSocketServerTest, it is @Ignored for now." C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/TCPSocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServer.java C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/AbstractSocketServerTest.java Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/AbstractSocketServerTest.java Deleting C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketServerTest.java Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/TCPSocketServerTest.java Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServer.java Adding C:/svn/org/apache/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/UDPSocketServerTest.java Transmitting file data ... Committed revision 1480747.
          Hide
          Remko Popma added a comment -

          Gary, the unit test problem (2nd event serialization fails) sounds familiar: LOG4J2-228 is also caused by a stream header issue.

          Show
          Remko Popma added a comment - Gary, the unit test problem (2nd event serialization fails) sounds familiar: LOG4J2-228 is also caused by a stream header issue.
          Hide
          Gary Gregory added a comment -

          Note that the header issue I see in the @Ignore test is affected by a timing factor. It does not always happen from the debugger.

          Show
          Gary Gregory added a comment - Note that the header issue I see in the @Ignore test is affected by a timing factor. It does not always happen from the debugger.
          Hide
          Ralph Goers added a comment -

          Fix committed in revision 1487289. Please verify and close.

          Show
          Ralph Goers added a comment - Fix committed in revision 1487289. Please verify and close.
          Hide
          Gary Gregory added a comment -

          Q: org.apache.logging.log4j.core.appender.AbstractAppender.error(String, LogEvent, Throwable) looks the same as org.apache.logging.log4j.core.appender.AbstractAppender.error(String, Throwable)

          Is that on purpose or the the LogEvent unused by mistake? Should it be logged? Should it be saved in the exception?

          With the code as is, there seems to be an opportunity for refactoring common code.

          Show
          Gary Gregory added a comment - Q: org.apache.logging.log4j.core.appender.AbstractAppender.error(String, LogEvent, Throwable) looks the same as org.apache.logging.log4j.core.appender.AbstractAppender.error(String, Throwable) Is that on purpose or the the LogEvent unused by mistake? Should it be logged? Should it be saved in the exception? With the code as is, there seems to be an opportunity for refactoring common code.
          Hide
          Ralph Goers added a comment -

          Are we looking at the same code? AbstractAppender.error(String, LogEvent, Throwable) and AbstractAppender.error(String, Throwable) are not the same and the LogEvent parameter is not unused. They call different ErrorHandler methods - one takes the LogEvent and one does not. It just so happens that both those methods perform the same action but they aren't required to.

          Show
          Ralph Goers added a comment - Are we looking at the same code? AbstractAppender.error(String, LogEvent, Throwable) and AbstractAppender.error(String, Throwable) are not the same and the LogEvent parameter is not unused. They call different ErrorHandler methods - one takes the LogEvent and one does not. It just so happens that both those methods perform the same action but they aren't required to.
          Hide
          Gary Gregory added a comment -

          Arg, please accept my apologies, I meant org.apache.logging.log4j.core.appender.DefaultErrorHandler.

          Show
          Gary Gregory added a comment - Arg, please accept my apologies, I meant org.apache.logging.log4j.core.appender.DefaultErrorHandler .
          Hide
          Ralph Goers added a comment -

          OK. I don't think this Jira issue is the correct place to discuss enhancements to DefaultErrorHandler.

          Show
          Ralph Goers added a comment - OK. I don't think this Jira issue is the correct place to discuss enhancements to DefaultErrorHandler.
          Hide
          Gary Gregory added a comment -

          OK, started a thread on the ML.

          Show
          Gary Gregory added a comment - OK, started a thread on the ML.

            People

            • Assignee:
              Unassigned
              Reporter:
              Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development