File tree Expand file tree Collapse file tree
gcloud-java-core/src/main/java/com/google/gcloud Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030
3131import java .io .BufferedReader ;
3232import java .io .File ;
33+ import java .io .FileNotFoundException ;
3334import java .io .FileReader ;
3435import java .io .IOException ;
3536import java .io .InputStream ;
@@ -387,8 +388,18 @@ protected static String googleCloudProjectId() {
387388 } else {
388389 configDir = new File (System .getProperty ("user.home" ), ".config/gcloud" );
389390 }
390- try (BufferedReader reader =
391- new BufferedReader (new FileReader (new File (configDir , "properties" )))) {
391+ FileReader fileReader ;
392+ try {
393+ fileReader = new FileReader (new File (configDir , "configurations/config_default" ));
394+ } catch (FileNotFoundException newConfigFileNotFoundEx ) {
395+ try {
396+ fileReader = new FileReader (new File (configDir , "properties" ));
397+ } catch (FileNotFoundException oldConfigFileNotFoundEx ) {
398+ // return null if we can't find config file
399+ return null ;
400+ }
401+ }
402+ try (BufferedReader reader = new BufferedReader (fileReader )) {
392403 String line ;
393404 String section = null ;
394405 Pattern projectPattern = Pattern .compile ("^project\\ s*=\\ s*(.*)$" );
You can’t perform that action at this time.
0 commit comments