File tree Expand file tree Collapse file tree 2 files changed +33
-8
lines changed
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern Expand file tree Collapse file tree 2 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -325,16 +325,15 @@ private Formatter getThreadLocalFormatter() {
325325 }
326326
327327 private void formatWithoutThreadLocals (final Instant instant , final StringBuilder output ) {
328- CachedTime cached = cachedTime .get ();
328+ final CachedTime effective ;
329+ final CachedTime cached = cachedTime .get ();
329330 if (instant .getEpochSecond () != cached .epochSecond || instant .getNanoOfSecond () != cached .nanoOfSecond ) {
330- final CachedTime newTime = new CachedTime (instant );
331- if (cachedTime .compareAndSet (cached , newTime )) {
332- cached = newTime ;
333- } else {
334- cached = cachedTime .get ();
335- }
331+ effective = new CachedTime (instant );
332+ cachedTime .compareAndSet (cached , effective );
333+ } else {
334+ effective = cached ;
336335 }
337- output .append (cached .formatted );
336+ output .append (effective .formatted );
338337 }
339338
340339 /**
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
4+ ~ contributor license agreements. See the NOTICE file distributed with
5+ ~ this work for additional information regarding copyright ownership.
6+ ~ The ASF licenses this file to you under the Apache License, Version 2.0
7+ ~ (the "License"); you may not use this file except in compliance with
8+ ~ the License. You may obtain a copy of the License at
9+ ~
10+ ~ http://www.apache.org/licenses/LICENSE-2.0
11+ ~
12+ ~ Unless required by applicable law or agreed to in writing, software
13+ ~ distributed under the License is distributed on an "AS IS" BASIS,
14+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ ~ See the License for the specific language governing permissions and
16+ ~ limitations under the License.
17+ -->
18+ <entry xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
19+ xmlns =" http://logging.apache.org/log4j/changelog"
20+ xsi : schemaLocation =" http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.1.xsd"
21+ type =" fixed" >
22+ <issue id =" 1485" link =" https://github.com/apache/logging-log4j2/issues/1485" />
23+ <author name =" Stephan Markwalder" id =" smarkwal" />
24+ <author id =" vy" />
25+ <description format =" asciidoc" >Fix concurrent date-time formatting issue in `PatternLayout`</description >
26+ </entry >
You can’t perform that action at this time.
0 commit comments