Skip to content

Commit 8f06886

Browse files
committed
Don't use UrlFetchTransport in App Engine Flex environment #1492
1 parent 58d7edf commit 8f06886

5 files changed

Lines changed: 56 additions & 4 deletions

File tree

google-cloud-core/src/main/java/com/google/cloud/HttpTransportOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public static class DefaultHttpTransportFactory implements HttpTransportFactory
5050

5151
@Override
5252
public HttpTransport create() {
53-
// Consider App Engine
54-
if (ServiceOptions.getAppEngineAppId() != null) {
53+
// Consider App Engine Standard
54+
if (System.getProperty("com.google.appengine.runtime.version") != null
55+
&& System.getenv("GAE_SERVICE") == null) {
5556
try {
5657
return new UrlFetchTransport();
5758
} catch (Exception ignore) {

testing/google-cloud-appengine-java8/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<plugin>
4343
<groupId>org.apache.maven.plugins</groupId>
44-
<version>3.3</version>
44+
<version>3.5.1</version>
4545
<artifactId>maven-compiler-plugin</artifactId>
4646
<configuration>
4747
<source>${java.source.version}</source>

testing/google-cloud-appengine-java8/src/main/webapp/WEB-INF/appengine-web.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
<manual-scaling>
1010
<instances>1</instances>
1111
</manual-scaling>
12+
<url-stream-handler>native</url-stream-handler>
1213
</appengine-web-app>

testing/google-cloud-managed-test/src/main/java/com/google/cloud/managed/test/GcjFlexTestServlet.java renamed to testing/google-cloud-managed-test/src/main/java/com/google/cloud/managed/test/GaeGcjTestServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import javax.servlet.http.HttpServletResponse;
3030

3131
@WebServlet(name = "flex", value = "/test")
32-
public class GcjFlexTestServlet extends HttpServlet {
32+
public class GaeGcjTestServlet extends HttpServlet {
3333

3434
private static final long serialVersionUID = 523885428311420041L;
3535

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2017 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.managed.test;
17+
18+
import java.io.IOException;
19+
import java.io.PrintWriter;
20+
import java.util.Map;
21+
import javax.servlet.ServletException;
22+
import javax.servlet.annotation.WebServlet;
23+
import javax.servlet.http.HttpServlet;
24+
import javax.servlet.http.HttpServletRequest;
25+
import javax.servlet.http.HttpServletResponse;
26+
27+
@WebServlet(name = "hex", value = "/info")
28+
public class GaeInfoServlet extends HttpServlet {
29+
30+
private static final long serialVersionUID = -3598229312089602597L;
31+
32+
@Override
33+
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
34+
throws ServletException, IOException {
35+
resp.setContentType("text");
36+
37+
PrintWriter out = resp.getWriter();
38+
out.append("\nENVIRONMENT VARIABLES:\n\n");
39+
40+
Map<String, String> envVars = System.getenv();
41+
for (Map.Entry<String, String> entry : envVars.entrySet()) {
42+
out.append(entry.getKey()).append("=").append(entry.getValue()).append('\n');
43+
}
44+
45+
out.append("\n\nSYSTEM PROPERTIES:\n\n");
46+
System.getProperties().list(out);
47+
48+
out.close();
49+
}
50+
}

0 commit comments

Comments
 (0)