Log4j 2
  1. Log4j 2
  2. LOG4J2-234

RegexFilter crashes as context-wide filter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta5
    • Fix Version/s: 2.0-beta6
    • Component/s: Filters
    • Labels:
      None

      Description

      If a RegexFilter is used as a context-wide filter,
      then a call like
      logger.isDebugEnabled()
      leads to a Null-Pointer-Exception, because the RegexFilter is called with the message "null".
      The stack-trace (2.0-beta5) is:
      at org.apache.logging.log4j.core.filter.RegexFilter.filter(RegexFilter.java:60)
      at org.apache.logging.log4j.core.filter.CompositeFilter.filter(CompositeFilter.java:176)
      at org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:317)
      at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:128)
      at org.apache.logging.log4j.spi.AbstractLogger.isTraceEnabled(AbstractLogger.java:1129)

      In the MarkerFilter is the code
      return marker != null && ...
      i.e. it is only necessary to change line 60 to
      return msg != null && filter(msg.toString)
      in RegexFilter (I do not know how to do this correctly...)

      In line 77, this check is done; in line 66 and 72 the same problem may arise...

      Greetings,
      Gerald Kroisandt

        Activity

        Hide
        Ralph Goers added a comment -

        Thanks for the bug report! The fix was applied in revision 1479050. Please verify and close.

        Show
        Ralph Goers added a comment - Thanks for the bug report! The fix was applied in revision 1479050. Please verify and close.
        Hide
        Gerald Kroisandt added a comment -

        I looked at the source code and in my opinion it should work now

        Show
        Gerald Kroisandt added a comment - I looked at the source code and in my opinion it should work now

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Gerald Kroisandt
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development