Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jackson.version>2.9.5</jackson.version>
<spark.version>2.7.2</spark.version>
<spark.version>2.8.0</spark.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion aws-serverless-java-container-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</parent>

<properties>
<spark.version>2.7.2</spark.version>
<spark.version>2.8.0</spark.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import spark.ExceptionMapper;
import spark.embeddedserver.EmbeddedServer;
import spark.embeddedserver.jetty.websocket.WebSocketHandlerWrapper;
import spark.http.matching.MatcherFilter;
Expand All @@ -24,6 +25,7 @@ public class LambdaEmbeddedServer
//-------------------------------------------------------------

private Routes applicationRoutes;
private ExceptionMapper exceptionMapper;
private MatcherFilter sparkFilter;
private StaticFilesConfiguration staticFilesConfiguration;
private boolean hasMultipleHandler;
Expand All @@ -34,14 +36,15 @@ public class LambdaEmbeddedServer
// Constructors
//-------------------------------------------------------------

LambdaEmbeddedServer(Routes routes, StaticFilesConfiguration filesConfig, boolean multipleHandlers) {
LambdaEmbeddedServer(Routes routes, StaticFilesConfiguration filesConfig, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
Timer.start("SPARK_EMBEDDED_SERVER_CONSTRUCTOR");
applicationRoutes = routes;
staticFilesConfiguration = filesConfig;
hasMultipleHandler = multipleHandlers;
this.exceptionMapper = exceptionMapper;

// try to initialize the filter here.
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, true, hasMultipleHandler);
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, exceptionMapper, true, hasMultipleHandler);
Timer.stop("SPARK_EMBEDDED_SERVER_CONSTRUCTOR");
}

Expand All @@ -50,17 +53,17 @@ public class LambdaEmbeddedServer
// Implementation - EmbeddedServer
//-------------------------------------------------------------
@Override
public int ignite(String s, int i, SslStores sslStores, int i1, int i2, int i3)
public int ignite(String host, int port, SslStores sslStores, int maxThreads, int minThreads, int threadIdleTimeoutMillis)
throws ContainerInitializationException {
Timer.start("SPARK_EMBEDDED_IGNITE");
log.info("Starting Spark server, ignoring port and host");
// if not initialized yet
if (sparkFilter == null) {
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, true, hasMultipleHandler);
sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, exceptionMapper, true, hasMultipleHandler);
}
sparkFilter.init(null);
Timer.stop("SPARK_EMBEDDED_IGNITE");
return i;
return port;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.amazonaws.serverless.proxy.internal.testutils.Timer;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import spark.ExceptionMapper;
import spark.embeddedserver.EmbeddedServer;
import spark.embeddedserver.EmbeddedServerFactory;
import spark.route.Routes;
Expand Down Expand Up @@ -39,10 +40,10 @@ public LambdaEmbeddedServerFactory(LambdaEmbeddedServer server) {


@Override
public EmbeddedServer create(Routes routes, StaticFilesConfiguration staticFilesConfiguration, boolean multipleHandlers) {
public EmbeddedServer create(Routes routes, StaticFilesConfiguration staticFilesConfiguration, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
Timer.start("SPARK_SERVER_FACTORY_CREATE");
if (embeddedServer == null) {
LambdaEmbeddedServerFactory.embeddedServer = new LambdaEmbeddedServer(routes, staticFilesConfiguration, multipleHandlers);
LambdaEmbeddedServerFactory.embeddedServer = new LambdaEmbeddedServer(routes, staticFilesConfiguration, exceptionMapper, multipleHandlers);
}
Timer.stop("SPARK_SERVER_FACTORY_CREATE");
return embeddedServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


public class LambdaEmbeddedServerTest {
private static LambdaEmbeddedServer server = new LambdaEmbeddedServer(null, null, false);
private static LambdaEmbeddedServer server = new LambdaEmbeddedServer(null, null, null, false);

@Test
public void webSocket_configureWebSocket_noException() {
Expand Down
4 changes: 2 additions & 2 deletions samples/spark/pet-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jackson.version>2.9.4</jackson.version>
<spark.version>2.7.2</spark.version>
<spark.version>2.8.0</spark.version>
</properties>

<dependencies>
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-spark</artifactId>
<version>[0.1,)</version>
<version>[0.2,)</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.sparkjava/spark-core -->
Expand Down