Skip to content

Commit eba3bad

Browse files
committed
Minor changes attempting to fix Spark unit tests
1 parent 76b7ff3 commit eba3bad

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsLambdaServletContainerHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected void setServletContext(final ServletContext context) {
166166
servletContext = context;
167167
// We assume custom implementations of the RequestWriter for HttpServletRequest will reuse
168168
// the existing AwsServletContext object since it has no dependencies other than the Lambda context
169-
filterChainManager = new AwsFilterChainManager((AwsServletContext)context);
169+
filterChainManager = new AwsFilterChainManager((AwsServletContext)servletContext);
170170
}
171171

172172
protected FilterChain getFilterChain(ContainerRequestType req, Servlet servlet) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,16 @@ protected void handleRequest(AwsProxyHttpServletRequest httpServletRequest, AwsH
160160

161161
if (embeddedServer == null) {
162162
log.debug("First request, getting new server instance");
163-
embeddedServer = LambdaEmbeddedServerFactory.getServerInstance();
163+
164+
// trying to call init in case the embedded server had not been initialized.
165+
Spark.init();
164166

165167
// adding this call to make sure that the framework is fully initialized. This should address a race
166168
// condition and solve GitHub issue #71.
167169
Spark.awaitInitialization();
168170

171+
embeddedServer = LambdaEmbeddedServerFactory.getServerInstance();
172+
169173
// call the onStartup event if set to give developers a chance to set filters in the context
170174
if (startupHandler != null) {
171175
startupHandler.onStartup(getServletContext());

0 commit comments

Comments
 (0)