[logback-dev] [JIRA] Resolved: (LBCORE-134) Joran XML Parser sometimes misses white space characters from element bodies
Ceki Gulcu (JIRA)
noreply-jira at qos.ch
Wed Feb 10 23:36:33 CET 2010
[ http://jira.qos.ch/browse/LBCORE-134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ceki Gulcu resolved LBCORE-134.
-------------------------------
Fix Version/s: 0.9.19
Resolution: Fixed
Hello Michael,
Thank you for reporting this bug, and in particular for identifying its origin. It was fixed in a recent commit:
http://github.com/ceki/logback/commit/4e5aba2f2489bd7d2a1f8284202a8cf7d3373a22
> Joran XML Parser sometimes misses white space characters from element bodies
> ----------------------------------------------------------------------------
>
> Key: LBCORE-134
> URL: http://jira.qos.ch/browse/LBCORE-134
> Project: logback-core
> Issue Type: Bug
> Components: Joran
> Affects Versions: 0.9.18
> Reporter: Michael Franz
> Assignee: Ceki Gulcu
> Priority: Critical
> Fix For: 0.9.19
>
>
> I have the following example configuration:
> <property name="Layout1" value="[Layout1] "xyz""/>
> <appender name="LayoutTest_Console" class="ch.qos.logback.core.ConsoleAppender">
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>TRACE</level>
> </filter>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <Pattern>
> [%date{yyyy-MM-dd HH:mm:ss.SSS}] ${Layout1} [Layout2] "xyz"%n
> </Pattern>
> </layout>
> </appender>
> and this produces the following output:
> [2010-01-05 13:06:34.897] [Layout1] "xyz" [Layout2]"xyz"
> Notice the missing space between [Layout2] and "xyz" in the output that was present in the configuration.
> The investigation shows a bug in ch.qos.logback.core.joran.event.SaxEventRecorder:
> public void characters(char[] ch, int start, int length) {
> String body = new String(ch, start, length);
> if (body == null) {
> return;
> }
> // if the body string is null
> if (body != null) {
> String bodyTrimmed = body.trim();
> if (bodyTrimmed.length() == 0) {
> return;
> }
> }
> SaxEvent lastEvent = getLastEvent();
> if (lastEvent instanceof BodyEvent) {
> BodyEvent be = (BodyEvent) lastEvent;
> be.append(body);
> } else {
> saxEventList.add(new BodyEvent(body, getLocator()));
> }
> }
> In my case the following calls were made to this method:
> 1. "[%date{yyyy-MM-dd HH:mm:ss.SSS}] ${Layout1} [Layout2]"
> 2. " "
> 3. """
> 4. "xyz"
> 5. """
> 6. "%n".
> Note that the calls actually performed depend on the actual body content within the file and the actually used SAX parser (in my case com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser).
> So within the method the:
> // if the body string is null
> if (body != null) {
> String bodyTrimmed = body.trim();
> if (bodyTrimmed.length() == 0) {
> return;
> }
> }
> must not occur if the last event was already a BodyEvent.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list