From b14301bfba93b93ae068d0353b220830c38014d8 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 7 Mar 2018 17:44:24 +0100 Subject: [PATCH] Allow TestContextManager to be compiled in Eclipse again --- .../test/context/TestContextManager.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java index 7dc086f74dc..297c8b2e884 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -94,8 +95,15 @@ public class TestContextManager { private final TestContext testContext; - private final ThreadLocal testContextHolder = - ThreadLocal.withInitial(() -> copyTestContext(TestContextManager.this.testContext)); + private final ThreadLocal testContextHolder = ThreadLocal.withInitial( + // Implemented as an anonymous inner class instead of a lambda expression due to a bug + // in Eclipse IDE: "The blank final field testContext may not have been initialized" + new Supplier() { + @Override + public TestContext get() { + return copyTestContext(TestContextManager.this.testContext); + } + }); private final List testExecutionListeners = new ArrayList<>();