Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1929

EOFException with FormattedMessage

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8.2
    • 2.9.0
    • API
    • None

    Description

      From https://github.com/apache/logging-log4j2/pull/78:

      To pass FormattedMessage completely we should pass string values from argArray together with argArray.length.
      For now there is such bug: on readObject it's InputStream brings length of stringArgs but there is no values in InputStream to read. So if length > 0 there will be EOFException while reading null value from InputStream.

      The unit test without the fix yields:

      java.io.EOFException
      	at java.base/java.io.DataInputStream.readUnsignedShort(Unknown Source)
      	at java.base/java.io.ObjectInputStream$BlockDataInputStream.readUnsignedShort(Unknown Source)
      	at java.base/java.io.ObjectInputStream$BlockDataInputStream.readUTF(Unknown Source)
      	at java.base/java.io.ObjectInputStream.readUTF(Unknown Source)
      	at org.apache.logging.log4j.message.FormattedMessage.readObject(FormattedMessage.java:241)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      	at java.base/java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      	at java.base/java.io.ObjectInputStream.readSerialData(Unknown Source)
      	at java.base/java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      	at java.base/java.io.ObjectInputStream.readObject0(Unknown Source)
      	at java.base/java.io.ObjectInputStream.readObject(Unknown Source)
      	at org.apache.logging.log4j.message.FormattedMessageTest.testSerialization(FormattedMessageTest.java:169)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: