Skip to content

Commit 99cf256

Browse files
ludochgae-java-bot
authored andcommitted
Move AppInfoFactory to a common package as it is not Jetty specific and can be shared across all Jetty versions.
PiperOrigin-RevId: 865965002 Change-Id: I04d68e5e83ee9219c20b4fac974070a400bbb662
1 parent c269e0f commit 99cf256

File tree

28 files changed

+36
-840
lines changed

28 files changed

+36
-840
lines changed

runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/AppInfoFactory.java renamed to runtime/impl/src/main/java/com/google/apphosting/runtime/AppInfoFactory.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.apphosting.runtime.jetty9;
17+
package com.google.apphosting.runtime;
18+
1819

1920
import com.google.apphosting.base.protos.AppinfoPb;
20-
import com.google.apphosting.utils.config.AppYaml;
2121
import java.io.File;
2222
import java.io.IOException;
2323
import java.nio.file.NoSuchFileException;
@@ -84,17 +84,9 @@ public AppinfoPb.AppInfo getAppInfoFromFile(String applicationRoot, String fixed
8484
return getAppInfo();
8585
}
8686

87-
public AppinfoPb.AppInfo getAppInfoFromAppYaml(AppYaml unused) throws IOException {
88-
return getAppInfo();
89-
}
9087

91-
public AppinfoPb.AppInfo getAppInfo() {
92-
final AppinfoPb.AppInfo.Builder appInfoBuilder =
93-
AppinfoPb.AppInfo.newBuilder()
94-
.setAppId(gaeApplication)
95-
.setVersionId(gaeVersion)
96-
.setRuntimeId("java8");
9788

98-
return appInfoBuilder.build();
89+
public AppinfoPb.AppInfo getAppInfo() {
90+
return AppinfoPb.AppInfo.newBuilder().setAppId(gaeApplication).setVersionId(gaeVersion).build();
9991
}
10092
}

runtime/runtime_impl_jetty9/src/test/java/com/google/apphosting/runtime/jetty9/AppInfoFactoryTest.java renamed to runtime/impl/src/test/java/com/google/apphosting/runtime/AppInfoFactoryTest.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.apphosting.runtime.jetty9;
17+
package com.google.apphosting.runtime;
1818

1919
import static com.google.common.base.StandardSystemProperty.USER_DIR;
2020
import static com.google.common.truth.Truth.assertThat;
21-
import static java.nio.charset.StandardCharsets.UTF_8;
2221
import static org.junit.Assert.assertThrows;
2322

2423
import com.google.appengine.tools.development.resource.ResourceExtractor;
2524
import com.google.apphosting.base.protos.AppinfoPb;
26-
import com.google.apphosting.utils.config.AppYaml;
2725
import com.google.common.collect.ImmutableMap;
28-
import java.io.File;
29-
import java.io.FileInputStream;
3026
import java.io.IOException;
31-
import java.io.InputStreamReader;
3227
import java.nio.file.NoSuchFileException;
3328
import java.nio.file.Path;
34-
import java.nio.file.Paths;
3529
import org.junit.Before;
3630
import org.junit.Rule;
3731
import org.junit.Test;
@@ -53,16 +47,15 @@ public final class AppInfoFactoryTest {
5347

5448
@Before
5549
public void setUp() throws IOException {
56-
Path projPath = Paths.get(temporaryFolder.newFolder(PROJECT_RESOURCE_NAME).getPath());
50+
Path projPath = Path.of(temporaryFolder.newFolder(PROJECT_RESOURCE_NAME).getPath());
5751
appRoot = projPath.getParent().toString();
58-
fixedAppDir = Paths.get(projPath.toString(), "100.mydeployment").toString();
52+
fixedAppDir = Path.of(projPath.toString(), "100.mydeployment").toString();
5953
ResourceExtractor.toFile(PROJECT_RESOURCE_NAME, projPath.toString());
6054
}
6155

6256
@Test
6357
public void getGaeService_nonDefault() throws Exception {
64-
AppInfoFactory factory =
65-
new AppInfoFactory(ImmutableMap.of("GAE_SERVICE", "mytestservice"));
58+
AppInfoFactory factory = new AppInfoFactory(ImmutableMap.of("GAE_SERVICE", "mytestservice"));
6659
assertThat(factory.getGaeService()).isEqualTo("mytestservice");
6760
}
6861

@@ -140,7 +133,6 @@ public void getAppInfo_fixedApplicationPath() throws Exception {
140133

141134
assertThat(appInfo.getAppId()).isEqualTo("s~myapp");
142135
assertThat(appInfo.getVersionId()).isEqualTo("mytestservice:100.mydeployment");
143-
assertThat(appInfo.getRuntimeId()).isEqualTo("java8");
144136
}
145137

146138
@Test
@@ -157,7 +149,6 @@ public void getAppInfo_appRoot() throws Exception {
157149

158150
assertThat(appInfo.getAppId()).isEqualTo("s~myapp");
159151
assertThat(appInfo.getVersionId()).isEqualTo("mytestservice:100.mydeployment");
160-
assertThat(appInfo.getRuntimeId()).isEqualTo("java8");
161152
}
162153

163154
@Test
@@ -179,7 +170,7 @@ public void getAppInfo_noAppYaml() throws Exception {
179170

180171
assertThat(appInfo.getAppId()).isEqualTo("s~myapp");
181172
assertThat(appInfo.getVersionId()).isEqualTo("mytestservice:100.mydeployment");
182-
assertThat(appInfo.getRuntimeId()).isEqualTo("java8");
173+
assertThat(appInfo.getApiVersion()).isEmpty();
183174
}
184175

185176
@Test
@@ -208,14 +199,10 @@ public void getAppInfo_givenAppYaml() throws Exception {
208199
"GAE_APPLICATION", "s~myapp",
209200
"GOOGLE_CLOUD_PROJECT", "mytestproject"));
210201

211-
File appYamlFile = new File(fixedAppDir + "/WEB-INF/appengine-generated/app.yaml");
212-
AppYaml appYaml = AppYaml.parse(new InputStreamReader(new FileInputStream(appYamlFile), UTF_8));
213-
214-
AppinfoPb.AppInfo appInfo = factory.getAppInfoFromAppYaml(appYaml);
202+
AppinfoPb.AppInfo appInfo = factory.getAppInfo();
215203

216204
assertThat(appInfo.getAppId()).isEqualTo("s~myapp");
217205
assertThat(appInfo.getVersionId()).isEqualTo("mytestservice:100.mydeployment");
218-
assertThat(appInfo.getRuntimeId()).isEqualTo("java8");
219206
}
220207

221208
@Test
@@ -233,6 +220,5 @@ public void getAppInfo_givenVersion() throws Exception {
233220

234221
assertThat(appInfo.getAppId()).isEqualTo("s~myapp");
235222
assertThat(appInfo.getVersionId()).isEqualTo("mytestservice:100.mydeployment");
236-
assertThat(appInfo.getRuntimeId()).isEqualTo("java8");
237223
}
238224
}

runtime/impl/src/test/resources/com/google/apphosting/runtime/jetty9/mytestproject/100.mydeployment/WEB-INF/appengine-generated/app.yaml renamed to runtime/impl/src/test/resources/com/google/apphosting/runtime/mytestproject/100.mydeployment/WEB-INF/appengine-generated/app.yaml

File renamed without changes.

runtime/lite/src/main/java/com/google/appengine/runtime/lite/AppEngineRuntime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
import com.google.apphosting.base.protos.AppinfoPb;
2424
import com.google.apphosting.runtime.ApiDeadlineOracle;
2525
import com.google.apphosting.runtime.ApiProxyImpl;
26+
import com.google.apphosting.runtime.AppInfoFactory;
2627
import com.google.apphosting.runtime.AppVersion;
2728
import com.google.apphosting.runtime.ApplicationEnvironment;
2829
import com.google.apphosting.runtime.SessionsConfig;
2930
import com.google.apphosting.runtime.anyrpc.APIHostClientInterface;
3031
import com.google.apphosting.runtime.http.HttpApiHostClientFactory;
3132
import com.google.apphosting.runtime.jetty9.AppEngineWebAppContext;
32-
import com.google.apphosting.runtime.jetty9.AppInfoFactory;
3333
import com.google.apphosting.runtime.jetty9.AppVersionHandlerFactory;
3434
import com.google.apphosting.runtime.jetty9.JettyServerConnectorWithReusePort;
3535
import com.google.apphosting.runtime.jetty9.WebAppContextFactory;

runtime/lite/src/main/java/com/google/appengine/runtime/lite/RequestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package com.google.appengine.runtime.lite;
1818

1919
import com.google.apphosting.runtime.AppVersion;
20+
import com.google.apphosting.runtime.AppInfoFactory;
2021
import com.google.apphosting.runtime.MutableUpResponse;
2122
import com.google.apphosting.runtime.anyrpc.AnyRpcServerContext;
22-
import com.google.apphosting.runtime.jetty9.AppInfoFactory;
2323
import com.google.apphosting.runtime.jetty9.AppVersionHandlerFactory;
2424
import com.google.apphosting.runtime.jetty9.UPRequestTranslator;
2525
import com.google.common.flogger.GoogleLogger;

runtime/lite/src/test/java/com/google/appengine/runtime/lite/AppEngineRuntimeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
import com.google.apphosting.runtime.ApiProxyImpl;
3636
import com.google.apphosting.runtime.AppVersion;
3737
import com.google.apphosting.runtime.ApplicationEnvironment;
38+
import com.google.apphosting.runtime.AppInfoFactory;
3839
import com.google.apphosting.runtime.SessionsConfig;
3940
import com.google.apphosting.runtime.http.FakeHttpApiHost;
40-
import com.google.apphosting.runtime.jetty9.AppInfoFactory;
4141
import com.google.apphosting.testing.PortPicker;
4242
import com.google.common.base.Joiner;
4343
import com.google.common.collect.ImmutableMap;

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/AppInfoFactory.java

Lines changed: 0 additions & 127 deletions
This file was deleted.

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/JettyServletEngineAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.apphosting.base.protos.RuntimePb.UPRequest;
2929
import com.google.apphosting.base.protos.RuntimePb.UPResponse;
3030
import com.google.apphosting.runtime.AppEngineConstants;
31+
import com.google.apphosting.runtime.AppInfoFactory;
3132
import com.google.apphosting.runtime.AppVersion;
3233
import com.google.apphosting.runtime.LocalRpcContext;
3334
import com.google.apphosting.runtime.MutableUpResponse;

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyHttpHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,23 @@
2525
import com.google.apphosting.base.protos.RuntimePb;
2626
import com.google.apphosting.runtime.ApiProxyImpl;
2727
import com.google.apphosting.runtime.AppEngineConstants;
28+
import com.google.apphosting.runtime.AppInfoFactory;
2829
import com.google.apphosting.runtime.AppVersion;
2930
import com.google.apphosting.runtime.BackgroundRequestCoordinator;
3031
import com.google.apphosting.runtime.LocalRpcContext;
3132
import com.google.apphosting.runtime.RequestManager;
32-
import com.google.apphosting.runtime.RequestRunner;
3333
import com.google.apphosting.runtime.RequestRunner.EagerRunner;
3434
import com.google.apphosting.runtime.ResponseAPIData;
3535
import com.google.apphosting.runtime.ServletEngineAdapter;
3636
import com.google.apphosting.runtime.anyrpc.AnyRpcServerContext;
37-
import com.google.apphosting.runtime.jetty.AppInfoFactory;
3837
import com.google.common.flogger.GoogleLogger;
3938
import java.io.PrintWriter;
4039
import java.io.StringWriter;
4140
import java.time.Duration;
4241
import java.util.concurrent.TimeoutException;
4342
import org.eclipse.jetty.server.Handler;
44-
import org.eclipse.jetty.server.HttpStream;
4543
import org.eclipse.jetty.server.Request;
4644
import org.eclipse.jetty.server.Response;
47-
import org.eclipse.jetty.server.Server;
4845
import org.eclipse.jetty.util.Blocker;
4946
import org.eclipse.jetty.util.Callback;
5047

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
import com.google.apphosting.base.protos.HttpPb;
5656
import com.google.apphosting.base.protos.RuntimePb;
5757
import com.google.apphosting.base.protos.TracePb;
58+
import com.google.apphosting.runtime.AppInfoFactory;
5859
import com.google.apphosting.runtime.RequestAPIData;
5960
import com.google.apphosting.runtime.TraceContextHelper;
60-
import com.google.apphosting.runtime.jetty.AppInfoFactory;
6161
import com.google.common.base.Strings;
6262
import com.google.common.flogger.GoogleLogger;
6363
import java.net.InetSocketAddress;

0 commit comments

Comments
 (0)