diff --git a/src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java b/src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java index 9a4d7b6a..5c8b23c7 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java +++ b/src/main/java/com/microsoft/azure/functions/worker/broker/JavaFunctionBroker.java @@ -6,8 +6,6 @@ import java.net.URL; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; import com.microsoft.azure.functions.internal.spi.middleware.Middleware; import com.microsoft.azure.functions.rpc.messages.*; @@ -35,9 +33,10 @@ public class JavaFunctionBroker { private final Map> methods; private final ClassLoaderProvider classLoaderProvider; private String workerDirectory; - private final AtomicBoolean oneTimeLogicInitialized = new AtomicBoolean(false); + private volatile boolean oneTimeLogicInitialized = false; private volatile InvocationChainFactory invocationChainFactory; private volatile FunctionInstanceInjector functionInstanceInjector; + private final Object oneTimeLogicInitializationLock = new Object(); private FunctionInstanceInjector newInstanceInjector() { return new FunctionInstanceInjector() { @@ -63,9 +62,14 @@ public void loadMethod(FunctionMethodDescriptor descriptor, Map