Skip to content

Commit

Permalink
Issue #74 - only use deprecated servlet/filters logic for java8 runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts committed Jan 5, 2025
1 parent 85b4eac commit 71a1d19
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

import com.google.apphosting.api.ApiProxy;
import com.google.apphosting.api.ApiProxy.LogRecord;
import com.google.apphosting.runtime.jetty9.AppEngineAuthentication;
import com.google.apphosting.runtime.jetty9.ParseBlobUploadHandler;
import com.google.apphosting.runtime.jetty9.RequestListener;
import com.google.apphosting.runtime.jetty9.TransactionCleanupListener;
import com.google.apphosting.utils.servlet.DeferredTaskServlet;
import com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter;
import com.google.apphosting.utils.servlet.SessionCleanupServlet;
Expand All @@ -42,6 +38,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -82,6 +79,10 @@ public class AppEngineWebAppContext extends WebAppContext {
private static final int MAX_RESPONSE_SIZE = 32 * 1024 * 1024;
private static final boolean APP_IS_ASYNC =
Boolean.getBoolean(RpcConnection.ASYNC_ENABLE_PPROPERTY);
private static final boolean IS_JAVA_8_RUNTIME =
Objects.equals(System.getenv("GAE_RUNTIME"), "java8");
private static final ImmutableSet<HolderMatcher> EMPTY_SET =
ImmutableSet.<HolderMatcher>builder().build();

private static final String JETTY_PACKAGE = "org.eclipse.jetty.";

Expand Down Expand Up @@ -123,7 +124,7 @@ public boolean checkAlias(String path, Resource resource) {
}

public AppEngineWebAppContext(File appDir, String serverInfo) {
this(appDir, serverInfo, /*extractWar=*/ true);
this(appDir, serverInfo, /* extractWar= */ true);
}

public AppEngineWebAppContext(File appDir, String serverInfo, boolean extractWar) {
Expand Down Expand Up @@ -228,19 +229,17 @@ protected void startWebapp() throws Exception {
// - Ensure known runtime filters/servlets are instantiated from this classloader
// - Ensure known runtime mappings exist.
ServletHandler servletHandler = getServletHandler();
ImmutableSet<HolderMatcher> deprecations =
IS_JAVA_8_RUNTIME ? DEPRECATED_SERVLETS_FILTERS : EMPTY_SET;
TrimmedFilters trimmedFilters =
new TrimmedFilters(
servletHandler.getFilters(),
servletHandler.getFilterMappings(),
DEPRECATED_SERVLETS_FILTERS);
servletHandler.getFilters(), servletHandler.getFilterMappings(), deprecations);
trimmedFilters.ensure(
"CloudSqlConnectionCleanupFilter", JdbcMySqlConnectionCleanupFilter.class, "/*");

TrimmedServlets trimmedServlets =
new TrimmedServlets(
servletHandler.getServlets(),
servletHandler.getServletMappings(),
DEPRECATED_SERVLETS_FILTERS);
servletHandler.getServlets(), servletHandler.getServletMappings(), deprecations);
trimmedServlets.ensure("_ah_warmup", WarmupServlet.class, "/_ah/warmup");
trimmedServlets.ensure(
"_ah_sessioncleanup", SessionCleanupServlet.class, "/_ah/sessioncleanup");
Expand Down

0 comments on commit 71a1d19

Please sign in to comment.