Skip to content

Commit b14301b

Browse files
committed
Allow TestContextManager to be compiled in Eclipse again
1 parent 030bc22 commit b14301b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spring-test/src/main/java/org/springframework/test/context/TestContextManager.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.ArrayList;
2222
import java.util.Collections;
2323
import java.util.List;
24+
import java.util.function.Supplier;
2425

2526
import org.apache.commons.logging.Log;
2627
import org.apache.commons.logging.LogFactory;
@@ -94,8 +95,15 @@ public class TestContextManager {
9495

9596
private final TestContext testContext;
9697

97-
private final ThreadLocal<TestContext> testContextHolder =
98-
ThreadLocal.withInitial(() -> copyTestContext(TestContextManager.this.testContext));
98+
private final ThreadLocal<TestContext> testContextHolder = ThreadLocal.withInitial(
99+
// Implemented as an anonymous inner class instead of a lambda expression due to a bug
100+
// in Eclipse IDE: "The blank final field testContext may not have been initialized"
101+
new Supplier<TestContext>() {
102+
@Override
103+
public TestContext get() {
104+
return copyTestContext(TestContextManager.this.testContext);
105+
}
106+
});
99107

100108
private final List<TestExecutionListener> testExecutionListeners = new ArrayList<>();
101109

0 commit comments

Comments
 (0)