Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update GoogleUtils#getVersion() to use stable logic #1452

Merged
merged 3 commits into from Dec 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -89,20 +89,18 @@ public static synchronized KeyStore getCertificateTrustStore()
}

private static String getVersion() {
String version = GoogleUtils.class.getPackage().getImplementationVersion();
// in a non-packaged environment (local), there's no implementation version to read
if (version == null) {
// fall back to reading from a properties file - note this value is expected to be cached
try (InputStream inputStream =
GoogleUtils.class.getResourceAsStream("google-api-client.properties")) {
if (inputStream != null) {
Properties properties = new Properties();
properties.load(inputStream);
version = properties.getProperty("google-api-client.version");
}
} catch (IOException e) {
// ignore
// attempt to read the library's version from a properties file generated during the build
// this value should be read and cached for later use
String version = "unknown-version";
try (InputStream inputStream =
GoogleUtils.class.getResourceAsStream("/google-api-client.properties")) {
if (inputStream != null) {
final Properties properties = new Properties();
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
properties.load(inputStream);
version = properties.getProperty("google-http-client.version");
}
} catch (IOException e) {
// ignore
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
}
return version;
}
Expand Down