Skip to content

Commit 3254858

Browse files
committed
Fix JTL nested logging test
1 parent 923a43e commit 3254858

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@
2525
import org.apache.logging.log4j.core.test.appender.ListAppender;
2626
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
2727
import org.apache.logging.log4j.core.test.junit.Named;
28-
import org.apache.logging.log4j.internal.recycler.ThreadLocalRecyclerFactoryProvider;
29-
import org.apache.logging.log4j.spi.LoggingSystemProperty;
3028
import org.assertj.core.api.Assertions;
3129
import org.junit.jupiter.api.Test;
32-
import org.junitpioneer.jupiter.SetSystemProperty;
3330

3431
/**
35-
* Tests if logging while trying to encode an event causes thread local recycler to incorrectly share buffers and end up overriding layout's earlier encoding work.
32+
* Tests if logging while trying to encode an event causes the default recycler to incorrectly share buffers and end up overriding layout's earlier encoding work.
3633
*
3734
* @see <a href="https://issues.apache.org/jira/browse/LOG4J2-2368">LOG4J2-2368</a>
3835
*/
39-
@SetSystemProperty(key = LoggingSystemProperty.Constant.RECYCLER_FACTORY_PROPERTY, value = "threadLocal")
40-
public class ThreadLocalRecyclerNestedLoggingTest {
36+
public class NestedLoggingTest {
4137

4238
private static final class ThrowableLoggingInGetMessage extends RuntimeException {
4339

@@ -55,21 +51,14 @@ public String getMessage() {
5551
}
5652

5753
@Test
58-
@LoggerContextSource("threadLocalRecyclerNestedLogging.xml")
59-
public void nested_logging_should_not_pollute_thread_local(
54+
@LoggerContextSource("NestedLoggingTest.xml")
55+
public void nested_logging_should_work(
6056
final LoggerContext loggerContext,
6157
final @Named(value = "List1") ListAppender appender1,
6258
final @Named(value = "List2") ListAppender appender2) {
6359

64-
// Verify the recycler factory type
65-
final String actualRecyclerFactoryClassName =
66-
loggerContext.getConfiguration().getRecyclerFactory().getClass().getCanonicalName();
67-
final String expectedRecyclerFactoryClassName =
68-
ThreadLocalRecyclerFactoryProvider.class.getCanonicalName() + ".ThreadLocalRecyclerFactory";
69-
Assertions.assertThat(actualRecyclerFactoryClassName).isEqualTo(expectedRecyclerFactoryClassName);
70-
7160
// Perform nested logging
72-
final Logger logger = loggerContext.getLogger(ThreadLocalRecyclerNestedLoggingTest.class);
61+
final Logger logger = loggerContext.getLogger(NestedLoggingTest.class);
7362
logger.error("A", new ThrowableLoggingInGetMessage(logger));
7463

7564
// Collect logged messages
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
~ See the License for the specific language governing permissions and
1616
~ limitations under the License.
1717
-->
18-
<Configuration status="OFF" name="ThreadLocalRecyclerNestedLoggingTest">
18+
<Configuration status="OFF" name="NestedLoggingTest">
1919
<Properties>
2020
<Property name="eventTemplate">[{"$resolver": "message", "stringified": true}, {"$resolver": "exception", "field": "message"}]</Property>
2121
</Properties>

0 commit comments

Comments
 (0)