Bug 1350757 - (6.4.z) StringIndexOutOfBoundsException throw while formatting log
Summary: (6.4.z) StringIndexOutOfBoundsException throw while formatting log
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.4.7
Hardware: All
OS: All
unspecified
medium
Target Milestone: CR1
: EAP 6.4.16
Assignee: Fedor Gavrilov
QA Contact: Jiří Bílek
URL:
Whiteboard:
Depends On:
Blocks: eap6416-payload 1441888
TreeView+ depends on / blocked
 
Reported: 2016-06-28 10:05 UTC by Szczepan Kuzniarz
Modified: 2017-06-22 09:24 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-06-22 09:24:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBEAP-10684 0 Major Resolved (7.0.z) StringIndexOutOfBoundsException throw while formatting log with truncation 2017-08-28 13:42:50 UTC
Red Hat Issue Tracker LOGMGR-141 0 Major Resolved StringIndexOutOfBoundsException throw while formatting log with truncation 2017-08-28 13:42:51 UTC

Description Szczepan Kuzniarz 2016-06-28 10:05:58 UTC
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.


Actual results:

Exception is thrown.


Expected results:

Formatted log written.


Additional info:

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);

Comment 4 Jiří Bílek 2017-06-06 08:29:02 UTC
Verified with EAP 6.4.16.CP.CR1

Comment 5 Petr Penicka 2017-06-22 09:24:47 UTC
Released on June 20 2017 as part of the EAP 6.4.16 maintenance release.


Note You need to log in before you can comment on or make changes to this bug.