Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-10684

(7.0.z) StringIndexOutOfBoundsException throw while formatting log with truncation

    XMLWordPrintable

Details

    • EAP 7.0.8

    Description

      This is clone of https://issues.jboss.org/browse/LOGMGR-141

      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
              rstancel@redhat.com Radovan Stancel
              Jiří Bílek Jiří Bílek (Inactive)
              Jiří Bílek Jiří Bílek (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: