Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 479623167
Change-Id: I85e05cc9385d111d66ed89f68cf5df4b0941bae3
  • Loading branch information
ludoch authored and gae-java-bot committed Oct 7, 2022
1 parent 726c08b commit 4c3f964
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ public final class ClassPathUtilsTest {

@Before
public void setUp() throws Exception {
System.clearProperty("use.java11");
System.clearProperty("classpath.runtime-impl");
System.clearProperty("use.mavenjars");
System.clearProperty("classpath.appengine-api-legacy");
System.clearProperty("classpath.connector-j");
runtimeLocation = temporaryFolder.getRoot().getAbsolutePath();
Expand All @@ -49,34 +47,6 @@ private void createJava8Environment() throws Exception {
temporaryFolder.newFile("java_runtime_launcher");
}

@Test
public void verifyDefaultPropertiesAreConfigured() throws Exception {
createJava8Environment();
ClassPathUtils cpu = new ClassPathUtils();
assertThat(cpu.getConnectorJUrls()).hasLength(1);
assertThat(System.getProperty("classpath.runtime-impl"))
.isEqualTo(
runtimeLocation
+ "/runtime-impl.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/frozen_debugger.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/runtime-impl-third-party.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/runtime-appengine-api.jar");

assertThat(System.getProperty("classpath.runtime-shared"))
.isEqualTo(runtimeLocation + "/runtime-shared.jar");
assertThat(System.getProperty("classpath.connector-j"))
.isEqualTo(runtimeLocation + "/jdbc-mysql-connector.jar");

assertThat(cpu.getFrozenApiJar().getAbsolutePath())
.isEqualTo(runtimeLocation + "/appengine-api.jar");
}

@Test
public void verifyJava11PropertiesAreConfigured() throws Exception {
// we do not call createJava8Environment() so expect java11+
Expand All @@ -93,39 +63,9 @@ public void verifyJava11PropertiesAreConfigured() throws Exception {
.isEqualTo(runtimeLocation + "/appengine-api-1.0-sdk.jar");
}

@Test
public void verifyJetty94PropertiesAreConfigured() throws Exception {

createJava8Environment();
ClassPathUtils cpu = new ClassPathUtils();
assertThat(cpu.getConnectorJUrls()).hasLength(1);
assertThat(System.getProperty("classpath.runtime-impl"))
.isEqualTo(
runtimeLocation
+ "/runtime-impl.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/frozen_debugger.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/runtime-impl-third-party.jar"
+ PATH_SEPARATOR
+ runtimeLocation
+ "/runtime-appengine-api.jar");

assertThat(System.getProperty("classpath.runtime-shared"))
.isEqualTo(runtimeLocation + "/runtime-shared.jar");
assertThat(System.getProperty("classpath.connector-j"))
.isEqualTo(runtimeLocation + "/jdbc-mysql-connector.jar");

assertThat(cpu.getFrozenApiJar().getAbsolutePath())
.isEqualTo(runtimeLocation + "/appengine-api.jar");
}

@Test
public void verifyMavenJarsPropertiesAreConfigured() throws Exception {
createJava8Environment();
System.setProperty("use.mavenjars", "true");

ClassPathUtils cpu = new ClassPathUtils(new File("/my_app_root"));
assertThat(cpu.getConnectorJUrls()).hasLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class ClassPathUtils {
private static final Logger logger = Logger.getLogger(ClassPathUtils.class.getName());

private static final String RUNTIME_BASE_PROPERTY = "classpath.runtimebase";
private static final String USE_MAVENJARS = "use.mavenjars";
private static final String RUNTIME_IMPL_PROPERTY = "classpath.runtime-impl";
private static final String RUNTIME_SHARED_PROPERTY = "classpath.runtime-shared";
private static final String PREBUNDLED_PROPERTY = "classpath.prebundled";
Expand Down Expand Up @@ -69,30 +68,14 @@ public ClassPathUtils(File root) {
return;
}

boolean useMavenJars = Boolean.getBoolean(USE_MAVENJARS);
String runtimeImplJar = null;
String cloudDebuggerJar = null;
String cloudDebuggerJar = "frozen_debugger.jar";
String profilerJar = null;
if (System.getenv("GAE_PROFILER_MODE") != null) {
profilerJar = "profiler.jar"; // Close source, not in Maven.;
logger.log(Level.INFO, "AppEngine profiler enabled.");
}
// This is only for Java11 or later runtime:
if (Boolean.getBoolean("use.java11")) {
runtimeImplJar = "runtime-impl.jar";
// Java11: No need for Cloud Debugger special treatement, we rely on pure open source agent.
} else {
runtimeImplJar = "runtime-impl.jar";
cloudDebuggerJar = "frozen_debugger.jar";
}
List<String> runtimeClasspathEntries =
useMavenJars
? Arrays.asList("jars/runtime-impl.jar", cloudDebuggerJar, profilerJar)
: Arrays.asList(
runtimeImplJar,
cloudDebuggerJar,
"runtime-impl-third-party.jar",
"runtime-appengine-api.jar");
Arrays.asList("jars/runtime-impl.jar", cloudDebuggerJar, profilerJar);

String runtimeClasspath =
runtimeClasspathEntries.stream()
Expand All @@ -105,10 +88,6 @@ public ClassPathUtils(File root) {
runtimeClasspath =
System.getProperty(RUNTIME_IMPL_PROPERTY) + PATH_SEPARATOR + runtimeClasspath;
}
// Only for Java8g, TODO(b/122040046)
if (new File(runtimeBase, "runtime-rpc-plugins.jar").exists()) {
runtimeClasspath += ":" + runtimeBase + "/runtime-rpc-plugins.jar";
}
// Keep old properties for absolute compatibility if ever some public apps depend on them:
System.setProperty(RUNTIME_IMPL_PROPERTY, runtimeClasspath);
logger.log(Level.INFO, "Using runtime classpath: " + runtimeClasspath);
Expand All @@ -117,15 +96,10 @@ public ClassPathUtils(File root) {
// that when deploying with api_version: 1.0 in generated app.yaml
// we need to add our own legacy jar.
frozenApiJarFile = new File(new File(root, runtimeBase), "/appengine-api.jar");
if (useMavenJars) {
System.setProperty(RUNTIME_SHARED_PROPERTY, runtimeBase + "/jars/runtime-shared.jar");
System.setProperty(API_PROPERTY, "1.0=" + runtimeBase + "/jars/appengine-api-1.0-sdk.jar");
System.setProperty(
APPENGINE_API_LEGACY_PROPERTY, runtimeBase + "/jars/appengine-api-legacy.jar");
} else {
System.setProperty(RUNTIME_SHARED_PROPERTY, runtimeBase + "/runtime-shared.jar");
System.setProperty(API_PROPERTY, "1.0=" + runtimeBase + "/appengine-api.jar");
}
System.setProperty(RUNTIME_SHARED_PROPERTY, runtimeBase + "/jars/runtime-shared.jar");
System.setProperty(API_PROPERTY, "1.0=" + runtimeBase + "/jars/appengine-api-1.0-sdk.jar");
System.setProperty(
APPENGINE_API_LEGACY_PROPERTY, runtimeBase + "/jars/appengine-api-legacy.jar");
System.setProperty(CONNECTOR_J_PROPERTY, runtimeBase + "/jdbc-mysql-connector.jar");
System.setProperty(PREBUNDLED_PROPERTY, runtimeBase + "/conscrypt.jar");
System.setProperty(LEGACY_PROPERTY, runtimeBase + "/legacy.jar");
Expand Down

0 comments on commit 4c3f964

Please sign in to comment.