Skip to content

Commit b3e6920

Browse files
authored
Use std runtime (GoogleCloudPlatform#900)
1. sparkjava update to use standard runtime instead of a custom container 2. Get rid of MVM reference 3. Fix flex_compat GaeInfoServlet
1 parent 86b0293 commit b3e6920

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

flexible/gaeinfo/src/main/java/com/example/appengine/flex_compat/GaeInfoServlet.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.gson.GsonBuilder;
2323
import com.google.gson.JsonParser;
2424
import java.io.IOException;
25+
import java.lang.Exception;
2526
import java.util.Enumeration;
2627
import java.util.Map;
2728
import java.util.Properties;
@@ -83,27 +84,39 @@ public class GaeInfoServlet extends HttpServlet {
8384

8485
// Fetch Metadata
8586
String fetchMetadata(String key) throws IOException {
86-
Request request = new Request.Builder()
87-
.url(metadata + key)
88-
.addHeader("Metadata-Flavor", "Google")
89-
.get()
90-
.build();
91-
92-
Response response = ok.newCall(request).execute();
93-
return response.body().string();
87+
try {
88+
Request request = new Request.Builder()
89+
.url(metadata + key)
90+
.addHeader("Metadata-Flavor", "Google")
91+
.get()
92+
.build();
93+
94+
Response response = ok.newCall(request).execute();
95+
return response.body().string();
96+
} catch (Exception e) {
97+
log("fetchMetadata - "+metadata+key+": ", e);
98+
}
99+
return "";
94100
}
95101

96102
String fetchJsonMetadata(String prefix) throws IOException {
103+
String json = "";
104+
try {
97105
Request request = new Request.Builder()
98106
.url(metadata + prefix )
99107
.addHeader("Metadata-Flavor", "Google")
100108
.get()
101109
.build();
102110

103-
Response response = ok.newCall(request).execute();
104-
105-
// Convert json to prety json
106-
return gson.toJson(jp.parse(response.body().string()));
111+
Response response = ok.newCall(request).execute();
112+
// Convert json to prety json
113+
json = response.body().string();
114+
return gson.toJson(jp.parse(json));
115+
} catch (Exception e) {
116+
log("fetchJsonMetadata - "+metadata+prefix+" : ", e);
117+
log(" body: "+json);
118+
}
119+
return "{}";
107120
}
108121

109122
@Override
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
runtime: custom
1+
runtime: java
22
env: flex
3+
4+
runtime_config:
5+
jdk: openjdk8

flexible/sparkjava/src/main/docker/Dockerfile

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

flexible/sparkjava/src/main/resources/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="container" role="main">
1111
<div class="jumbotron">
1212
<h1>User Database</h1>
13-
<p>Using App Engine Managed VMs, Google Cloud Datastore, and SparkJava.</p>
13+
<p>Using App Engine Flexible, Google Cloud Datastore, and SparkJava.</p>
1414
</div>
1515
<div class="page-header">
1616
<h1>All users</h1>

0 commit comments

Comments
 (0)