File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
google-auth-library-java/oauth2_http/java/com/google/auth/oauth2 Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -364,9 +364,14 @@ public String getProjectId() {
364364
365365 String projectIdFromMetadata = getProjectIdFromMetadata ();
366366 synchronized (this ) {
367- this .projectId = projectIdFromMetadata ;
367+ // Check first if another thread set the Project ID. No need to overwrite
368+ // if a Projects ID already exists. Tries to prevent a case where the last call
369+ // for `getProjectIdFromMetadata()` returns null and overwrites valid data.
370+ if (this .projectId == null ) {
371+ this .projectId = projectIdFromMetadata ;
372+ }
368373 }
369- return projectIdFromMetadata ;
374+ return this . projectId ;
370375 }
371376
372377 private String getProjectIdFromMetadata () {
You can’t perform that action at this time.
0 commit comments