|
30 | 30 | import com.google.api.client.json.GenericJson;
|
31 | 31 | import com.google.api.client.json.JsonFactory;
|
32 | 32 | import com.google.api.client.json.JsonObjectParser;
|
33 |
| -import com.google.api.client.json.jackson2.JacksonFactory; |
34 |
| -import com.google.api.client.util.Charsets; |
| 33 | +import com.google.api.client.json.gson.GsonFactory; |
35 | 34 | import com.google.api.core.ApiClock;
|
36 | 35 | import com.google.api.core.BetaApi;
|
37 | 36 | import com.google.api.core.CurrentMillisClock;
|
|
61 | 60 | import java.io.ObjectInputStream;
|
62 | 61 | import java.io.Serializable;
|
63 | 62 | import java.nio.charset.Charset;
|
| 63 | +import java.nio.charset.StandardCharsets; |
64 | 64 | import java.util.Locale;
|
65 | 65 | import java.util.Map;
|
66 | 66 | import java.util.Objects;
|
@@ -516,19 +516,18 @@ protected static String getServiceAccountProjectId() {
|
516 | 516 |
|
517 | 517 | @InternalApi("Visible for testing")
|
518 | 518 | static String getValueFromCredentialsFile(String credentialsPath, String key) {
|
519 |
| - String value = null; |
520 | 519 | if (credentialsPath != null) {
|
521 | 520 | try (InputStream credentialsStream = new FileInputStream(credentialsPath)) {
|
522 |
| - JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); |
| 521 | + JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); |
523 | 522 | JsonObjectParser parser = new JsonObjectParser(jsonFactory);
|
524 | 523 | GenericJson fileContents =
|
525 |
| - parser.parseAndClose(credentialsStream, Charsets.UTF_8, GenericJson.class); |
526 |
| - value = (String) fileContents.get(key); |
527 |
| - } catch (IOException e) { |
528 |
| - // ignore |
| 524 | + parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class); |
| 525 | + return (String) fileContents.get(key); |
| 526 | + } catch (IOException | IllegalArgumentException ex) { |
| 527 | + return null; |
529 | 528 | }
|
530 | 529 | }
|
531 |
| - return value; |
| 530 | + return null; |
532 | 531 | }
|
533 | 532 |
|
534 | 533 | /**
|
|
0 commit comments