Skip to content

Commit 0433b6b

Browse files
committed
Still flying blind, move Spark filter initialization to constructor of the embedded server object
1 parent fb8d656 commit 0433b6b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class LambdaEmbeddedServer
3838
applicationRoutes = routes;
3939
staticFilesConfiguration = filesConfig;
4040
hasMultipleHandler = multipleHandlers;
41+
42+
// try to initialize the filter here.
43+
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, true, hasMultipleHandler);
4144
}
4245

4346

@@ -48,7 +51,10 @@ public class LambdaEmbeddedServer
4851
public int ignite(String s, int i, SslStores sslStores, int i1, int i2, int i3)
4952
throws Exception {
5053
log.info("Starting Spark server, ignoring port and host");
51-
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, false, hasMultipleHandler);
54+
// if not initialized yet
55+
if (sparkFilter == null) {
56+
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, true, hasMultipleHandler);
57+
}
5258

5359
return i;
5460
}

aws-serverless-java-container-spark/src/test/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandlerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void filters_onStartupMethod_executeFilters() {
3535
e.printStackTrace();
3636
fail();
3737
}
38-
38+
3939
handler.onStartup(c -> {
4040
if (c == null) {
4141
System.out.println("Null servlet context");

0 commit comments

Comments
 (0)