Skip to content

Commit 09854fa

Browse files
authored
---
yaml --- r: 8143 b: refs/heads/tswast-patch-1 c: ab261f0 h: refs/heads/master i: 8141: 30035a7 8139: 478dfc6 8135: d22ea14 8127: 4715f43
1 parent 723ce68 commit 09854fa

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: ba017e614a1130ae133b7d0042cb548ace33071e
60+
refs/heads/tswast-patch-1: ab261f046bf09d62e9c022295d335aca5f0e50d2
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.auth.http.HttpCredentialsAdapter;
2929
import com.google.auth.http.HttpTransportFactory;
3030
import com.google.cloud.NoCredentials;
31+
import com.google.cloud.PlatformInformation;
3132
import com.google.cloud.ServiceOptions;
3233
import com.google.cloud.TransportOptions;
3334
import java.io.IOException;
@@ -55,8 +56,7 @@ public static class DefaultHttpTransportFactory implements HttpTransportFactory
5556
@Override
5657
public HttpTransport create() {
5758
// Consider App Engine Standard
58-
if (System.getProperty("com.google.appengine.runtime.version") != null
59-
&& System.getenv("GAE_SERVICE") == null) {
59+
if (PlatformInformation.isOnGAEStandard7()) {
6060
try {
6161
return new UrlFetchTransport();
6262
} catch (Exception ignore) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
17+
package com.google.cloud;
18+
19+
import com.google.api.core.InternalApi;
20+
21+
@InternalApi("This class should only be used within google-cloud-java")
22+
public final class PlatformInformation {
23+
public static final String SPECIFICATION_VERSION =
24+
System.getProperty("java.specification.version");
25+
public static final String GAE_RUNTIME_VERSION =
26+
System.getProperty("com.google.appengine.runtime.version");
27+
public static final String RUNTIME_JETTY_LOGGER =
28+
System.getProperty("org.eclipse.jetty.util.log.class");
29+
public static final String JETTY_LOGGER_ON_GAE8_PROD =
30+
"com.google.apphosting.runtime.jetty9.JettyLogger";
31+
public static final String JETTY_LOGGER_ON_GAE8_DEVSERVER =
32+
" com.google.appengine.development.jetty9.JettyLogger"; //note the leading space
33+
34+
private PlatformInformation() {}
35+
36+
public static boolean isOnGAE() {
37+
return GAE_RUNTIME_VERSION != null;
38+
}
39+
40+
public static boolean isOnGAEStandard7() {
41+
//edge case: when a Java 7 GAE app is deployed to DevServer running on J8, SPECIFICATION_VERSION will be "1.8",
42+
//but RUNTIME_JETTY_LOGGER is unset
43+
return isOnGAE() && SPECIFICATION_VERSION.equals("1.7")
44+
|| isOnGAE() && RUNTIME_JETTY_LOGGER == null;
45+
}
46+
47+
public static boolean isOnGAEStandard8() {
48+
return isOnGAE()
49+
&& !SPECIFICATION_VERSION.equals("1.7")
50+
&& RUNTIME_JETTY_LOGGER != null
51+
&& (RUNTIME_JETTY_LOGGER.equals(JETTY_LOGGER_ON_GAE8_DEVSERVER)
52+
|| RUNTIME_JETTY_LOGGER.equals(JETTY_LOGGER_ON_GAE8_PROD));
53+
}
54+
}

0 commit comments

Comments
 (0)