Skip to content

Commit

Permalink
Merge pull request #80 from GoogleCloudPlatform:spring-boot-fixes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 583399120
Change-Id: I4ebdcda1d3c42a836a6a0a4cb07581b477f3e8b2
  • Loading branch information
gae-java-bot committed Nov 17, 2023
2 parents c1b0aa9 + 4a964d0 commit 02239c3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,31 @@ class DevAppServerClassLoader extends URLClassLoader {
* classes will be loaded (e.g. DevAppServer).
*/
public static DevAppServerClassLoader newClassLoader(ClassLoader delegate) {
List<URL> sharedLibs = AppengineSdk.getSdk().getSharedLibs();
List<URL> implLibs = AppengineSdk.getSdk().getImplLibs();
List<URL> userJspLibs = AppengineSdk.getSdk().getUserJspLibs();

// NB Doing shared, then impl, in order, allows us to prefer
// returning shared classes when asked by other classloaders. This makes
// it so that we don't have to have the impl and shared classes
// be a strictly disjoint set.
List<URL> libs = new ArrayList<>(AppengineSdk.getSdk().getSharedLibs());
libs.addAll(AppengineSdk.getSdk().getImplLibs());
// Needed by admin console servlets, which are loaded by this
// ClassLoader
libs.addAll(AppengineSdk.getSdk().getUserJspLibs());
return new DevAppServerClassLoader(libs.toArray(new URL[libs.size()]), delegate);
// returning shared classes when asked by other classloaders.
// This makes it so that we don't have to have the impl and
// shared classes be a strictly disjoint set.
List<URL> libs = new ArrayList<>(sharedLibs);
addLibs(libs, implLibs);

// Needed by admin console servlets, which are loaded by this ClassLoader.
addLibs(libs, userJspLibs);

return new DevAppServerClassLoader(libs.toArray(new URL[0]), delegate);
}

private static void addLibs(List<URL> libs, List<URL> toAdd)
{
for (URL url : toAdd)
{
if (libs.contains(url))
continue;
libs.add(url);
}
}

// NB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public DevAppEngineWebAppContext(File appDir, File externalResourceDir, String s

// Set up the classpath required to compile JSPs. This is specific to Jasper.
setAttribute(JASPER_SERVLET_CLASSPATH, buildClasspath());
setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/jakarta.servlet-api-[^/]*\\.jar$|.*jakarta.servlet.jsp.jstl-.*\\.jar$");

// Make ApiProxyLocal available via the servlet context. This allows
// servlets that are part of the dev appserver (like those that render the
Expand Down Expand Up @@ -94,14 +95,18 @@ protected ClassLoader configureClassLoader(ClassLoader loader) {
return loader;
}

@Override
protected void doStart() throws Exception {
super.doStart();
disableTransportGuarantee();
}

@Override
protected ClassLoader enterScope(Request contextRequest) {
if ((contextRequest != null) && (hasSkipAdminCheck(contextRequest))) {
contextRequest.setAttribute(SKIP_ADMIN_CHECK_ATTR, Boolean.TRUE);
}

disableTransportGuarantee();

// TODO An extremely heinous way of helping the DevAppServer's
// SecurityManager determine if a DevAppServer request thread is executing.
// Find something better.
Expand Down

0 comments on commit 02239c3

Please sign in to comment.