Skip to content

Commit 572d13a

Browse files
committed
Adding DirtiesContext to WithNestedClassContextTests
* To prevent a race condition on shutdown that is causing certain file operations to fail, we need to add `DirtiesContext` to `WithNestedClassContextTests.`
1 parent e547d0a commit 572d13a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spring-kafka-test/src/test/java/org/springframework/kafka/test/condition/WithNestedClassContextTests.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 the original author or authors.
2+
* Copyright 2021-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,10 +28,16 @@
2828
import org.springframework.context.annotation.Bean;
2929
import org.springframework.context.annotation.Configuration;
3030
import org.springframework.kafka.test.context.EmbeddedKafka;
31+
import org.springframework.test.annotation.DirtiesContext;
3132
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3233

34+
/**
35+
* @author Lee Jaeheon
36+
* @author Soby Chacko
37+
*/
3338
@EmbeddedKafka
3439
@SpringJUnitConfig(WithNestedClassContextTests.Config.class)
40+
@DirtiesContext
3541
class WithNestedClassContextTests {
3642

3743
private static final AtomicInteger counter = new AtomicInteger();
@@ -56,17 +62,20 @@ void equalsSize(@Autowired List<TestClass> classes) {
5662
void equalsCount() {
5763
assertThat(counter.get()).isEqualTo(1);
5864
}
59-
}
6065

61-
public static class TestClass {
6266
}
6367

68+
public static class TestClass { }
69+
6470
@Configuration
6571
static class Config {
72+
6673
@Bean
6774
public TestClass testClass() {
6875
counter.incrementAndGet();
6976
return new TestClass();
7077
}
78+
7179
}
80+
7281
}

0 commit comments

Comments
 (0)