Uploaded image for project: 'JBoss Log Manager'
  1. JBoss Log Manager
  2. LOGMGR-191

Amend NullPointerException in regex filters

XMLWordPrintable

    When log message is null, RegexFilter.isLoggable() throws NullPointerException.

    https://github.com/jboss-logging/jboss-logmanager/blob/master/src/main/java/org/jboss/logmanager/filters/RegexFilter.java#L63

    It often results in unexpected outcomes. For example, assuming you have a filter-spec with "not(match(xxx))" to suppress some messages in your logger configuration:

        <subsystem xmlns="urn:jboss:domain:logging:3.0">
                <console-handler name="CONSOLE">
                    <level name="INFO"/>
                    <filter-spec value="not(match(&quot;SOME_MESSAGE&quot;))"/>
                    <formatter>
                        <named-formatter name="COLOR-PATTERN"/>
                    </formatter>
                </console-handler>
    

    and an application has a code like this:

            try {
                ...
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
    

    "e.getMessage()" could be null. But you want to log the stacktrace 'e' anyway.

    In this case, NullPointerException is thrown from RegexFilter and reaches to LoggerNode and disappears. ConsoleHandler cannot publish the log at all.

    https://github.com/jboss-logging/jboss-logmanager/blob/master/src/main/java/org/jboss/logmanager/LoggerNode.java#L317-L319

    I think 'null' message should simply return 'false' in RegexFilter.isLoggable().

            jperkins-rhn James Perkins
            rhn-support-tkobayas Toshiya Kobayashi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: