[logback-dev] [JIRA] (LOGBACK-1270) PatternLayoutBase concurrent access race condition

QOS.CH (JIRA) noreply-jira at qos.ch
Wed Mar 1 17:11:00 CET 2017


Artem Bilan created LOGBACK-1270:
------------------------------------

             Summary: PatternLayoutBase concurrent access race condition
                 Key: LOGBACK-1270
                 URL: https://jira.qos.ch/browse/LOGBACK-1270
             Project: logback
          Issue Type: Bug
          Components: logback-core
    Affects Versions: 1.1.10
            Reporter: Artem Bilan
            Assignee: Logback dev list


I found the race condition in the Logback:

 
|PatternLayoutBase.java|
|{color:#000000}StringBuilder recycledStringBuilder = new StringBuilder(INTIAL_STRING_BUILDER_SIZE);{color}|
|{color:#000000}...{color}|
|{color:#000000}protected String writeLoopOnConverters(E event) \{{color}|
|{color:#000000} StringBuilder strBuilder = getRecycledStringBuilder();{color}|
|{color:#000000}...{color}|
|{color:#000000}}{color}|
| |
|{color:#000000} private StringBuilder getRecycledStringBuilder() \{{color}|
|{color:#000000} if (recycledStringBuilder.length() > MAX_STRING_BUILDER_LENGTH) \{{color}|
|{color:#000000} recycledStringBuilder = new StringBuilder(INTIAL_STRING_BUILDER_SIZE);{color}|
|{color:#000000} }{color}|
|{color:#000000} recycledStringBuilder.setLength(0);{color}|
|{color:#000000} return recycledStringBuilder;{color}|
|{color:#000000} } {color}|

 

So, when we have multi-threaded appender, we end up with the issue writing to the same {{StringBuilder}} concurrently.

See this consequent commits in Logback:
 [https://github.com/qos-ch/logback/commit/6ddea70a42055adb3a9d1dd844c2f2bb0333353b]
 [https://github.com/qos-ch/logback/commit/4938ee75971c9003e7a12ce0dadbadae8dd263c5]

The problem with the last one that it isn't backported to {{1.1.x}}.

 

Since the fix has been done in \{\{master}}, please, consider to backport it into \{\{1.1.x}}.



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list