You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sd...@apache.org on 2022/10/12 08:26:08 UTC

[ignite] branch master updated: IGNITE-17863 ThreadNameValidationTest fails if run alone (or first in suite) (#10301)

This is an automated email from the ASF dual-hosted git repository.

sdanilov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new c0f1eb78709 IGNITE-17863 ThreadNameValidationTest fails if run alone (or first in suite) (#10301)
c0f1eb78709 is described below

commit c0f1eb78709915d8582653f96f9bd5e1f569453b
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Wed Oct 12 12:26:00 2022 +0400

    IGNITE-17863 ThreadNameValidationTest fails if run alone (or first in suite) (#10301)
---
 .../ignite/internal/ThreadNameValidationTest.java    | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ThreadNameValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ThreadNameValidationTest.java
index 4f44e50cc06..cac45bdb5f6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ThreadNameValidationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ThreadNameValidationTest.java
@@ -34,6 +34,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.junits.GridAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -48,14 +49,19 @@ import org.junit.runners.model.Statement;
  */
 public class ThreadNameValidationTest extends GridCommonAbstractTest {
 
+    static {
+        // Make sure that log4j init happens before we fill #defaultThreadFactoryCountBeforeTest.
+        initLoggingSubsystem();
+    }
+
     /** {@link Executors.DefaultThreadFactory} count before test. */
-    private static transient int defaultThreadFactoryCountBeforeTest;
+    private static int defaultThreadFactoryCountBeforeTest;
 
     /** {@link Thread#threadInitNumber} count before test. */
-    private static transient int anonymousThreadCountBeforeTest;
+    private static int anonymousThreadCountBeforeTest;
 
     /** Sequence for sets objects. */
-    private static final transient AtomicLong SEQUENCE = new AtomicLong();
+    private static final AtomicLong SEQUENCE = new AtomicLong();
 
     /** */
     private static final TestRule beforeAllTestRule = (base, description) -> new Statement() {
@@ -75,6 +81,14 @@ public class ThreadNameValidationTest extends GridCommonAbstractTest {
     /** */
     private Set<Long> externalAnonymousThreads;
 
+    /**
+     * Makes sure that Log4j logging subsystem is initialized. This method must be invoked before
+     * #defaultThreadFactoryCountBeforeTest is filled as Log4j initialization creates a default thread factory.
+     */
+    private static void initLoggingSubsystem() {
+        new GridTestLog4jLogger();
+    }
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {