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

AbstractStringLayout implements Serializable, but is not Serializable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.3
    • None
    • Layouts
    • None

    Description

      org.apache.logging.log4j.core.layout.AbstractLayout line 34 :

          // TODO: Charset is not serializable. Implement read/writeObject() ?
          private final Charset charset;
      

      The developer has recognised that this class claims to be serializable, but is not actually serializable.

      This actually has wide impact due to the fact that the Logger is holding onto the Layout via the org.apache.logging.log4j.core.Logger.PrivateConfig#config (XML in my case). Many projects, including Spring, do not use static Loggers and prefer getClass type approaches off of their abstract classes, i.e.:

      protected final Log logger = LogFactory.getLog(getClass());
      

      This actually can lead to use of spring session beans, which are serialized with the session, trying to serialize the logger also and failing due to this bug.

      Attachments

        Issue Links

          Activity

            People

              mattsicker Matt Sicker
              louisburton Louis Burton
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: