Skip to content

Commit

Permalink
IGNITE-17863 ThreadNameValidationTest fails if run alone (or first in…
Browse files Browse the repository at this point in the history
… suite) (apache#10301)
  • Loading branch information
rpuch authored Oct 12, 2022
1 parent 6cb6dd2 commit c0f1eb7
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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;
Expand All @@ -48,14 +49,19 @@
*/
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() {
Expand All @@ -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 {

Expand Down

0 comments on commit c0f1eb7

Please sign in to comment.