Skip to content

Commit 76b7ff3

Browse files
committed
Moved awaitInitialization call in Spark handler
1 parent 9558e40 commit 76b7ff3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

aws-serverless-java-container-spark/src/main/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ protected void handleRequest(AwsProxyHttpServletRequest httpServletRequest, AwsH
162162
log.debug("First request, getting new server instance");
163163
embeddedServer = LambdaEmbeddedServerFactory.getServerInstance();
164164

165+
// adding this call to make sure that the framework is fully initialized. This should address a race
166+
// condition and solve GitHub issue #71.
167+
Spark.awaitInitialization();
168+
165169
// call the onStartup event if set to give developers a chance to set filters in the context
166170
if (startupHandler != null) {
167171
startupHandler.onStartup(getServletContext());
@@ -170,10 +174,6 @@ protected void handleRequest(AwsProxyHttpServletRequest httpServletRequest, AwsH
170174
// manually add the spark filter to the chain. This should the last one and match all uris
171175
FilterRegistration.Dynamic sparkRegistration = getServletContext().addFilter("SparkFilter", embeddedServer.getSparkFilter());
172176
sparkRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
173-
174-
// adding this call to make sure that the framework is fully initialized. This should address a race
175-
// condition and solve GitHub issue #71.
176-
Spark.awaitInitialization();
177177
}
178178

179179
doFilter(httpServletRequest, httpServletResponse, null);

0 commit comments

Comments
 (0)