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

StringIndexOutOfBoundsException throw while formatting log with truncation

    XMLWordPrintable

Description

    When value in left-justified field is longer than maximum width following exception is thrown:

    java.lang.StringIndexOutOfBoundsException
            at java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:733)
            at java.lang.StringBuilder.delete(StringBuilder.java:244)
            at org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:212)
            at org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:83)
            at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:32)
            at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:46)
            at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:76)
            at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:302)
            at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:310)
            at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:310)
            at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:310)
            at org.jboss.logmanager.Logger.logRaw(Logger.java:719)
            at org.jboss.logmanager.Logger.log(Logger.java:670)
            at org.jboss.logging.JBossLogManagerLogger.doLogf(JBossLogManagerLogger.java:50)
            at org.jboss.logging.Logger.logf(Logger.java:2096)
    

    Steps to Reproduce:

    1. Configure formatter with left-justified field with maximum width:

    /subsystem=logging/periodic-rotating-file-handler=FILE:write-attribute(name=formatter,value="%d{HH:mm:ss,SSS} %-5p [%c{1.}] [%-20.-20t] %s%E%n")
    

    (in the example above thread name should be truncated to 20 characters, left-justified)

    2. Write a log from a thread which has a name containg 21 characters or more. During server startup logs are written by "MSC service thread 1-7" thread.

    It seems there is an error in org.jboss.logmanager.formatters.Formatters() class, line 212. There is:

    builder.delete(oldLen, overflow + 1);
    

    but should be:

    builder.delete(oldLen, oldLen + overflow);
    

    Attachments

      Issue Links

        Activity

          People

            jperkins-rhn James Perkins
            jperkins-rhn James Perkins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: