Skip to content

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

Merged
chingor13 merged 3 commits into
googleapis:masterfrom
chingor13:version-constant
Dec 17, 2019
Merged

fix: update GoogleUtils#getVersion() to use stable logic#1452
chingor13 merged 3 commits into
googleapis:masterfrom
chingor13:version-constant

Conversation

@chingor13
Copy link
Copy Markdown
Collaborator

Fixes #1451

@chingor13 chingor13 requested a review from a team December 17, 2019 19:11
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 17, 2019
Copy link
Copy Markdown
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializerTest
[ERROR] testInitialize(com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializerTest) Time elapsed: 0 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.googleapis.GoogleUtils
at com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializerTest.testInitialize(CommonGoogleJsonClientRequestInitializerTest.java:47)

Comment thread google-api-client/src/main/java/com/google/api/client/googleapis/GoogleUtils.java Outdated
if (inputStream != null) {
final Properties properties = new Properties();
properties.load(inputStream);
version = properties.getProperty("google-api-client.version");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this could be null. You should supply a default here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. Moved the default to the return statement while checking for null.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or you could write

version = properties.getProperty("google-api-client.version". "unknown-version");

up to you.

if (inputStream != null) {
final Properties properties = new Properties();
properties.load(inputStream);
version = properties.getProperty("google-api-client.version");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or you could write

version = properties.getProperty("google-api-client.version". "unknown-version");

up to you.

@chingor13 chingor13 merged commit 744839f into googleapis:master Dec 17, 2019
@chingor13 chingor13 deleted the version-constant branch December 17, 2019 23:28
@Samikay
Copy link
Copy Markdown

Samikay commented Jan 11, 2020

Did this make it into 1.30.7? Cause it's still broken. Or is it because it's minified? I should test that...

 Caused by: java.lang.IllegalStateException: No successful match so far
    at java.util.regex.Matcher.ensureMatch(Matcher.java:1116)
    at java.util.regex.Matcher.group(Matcher.java:382)
    at c.c.b.a.c.a.<clinit>(:66)
    at com.google.api.services.drive.Drive.<clinit>(:44) 
    at com.google.api.services.drive.Drive$Builder.build(:9813) 

Post-edit: Nevermind, proguard issue. Needed this to stop the crash:
-keep class com.google.api.client.googleapis.** { *; }

Sorry about that.

@elharo
Copy link
Copy Markdown
Contributor

elharo commented Jan 11, 2020

related #1467

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.

Android/Java 1.30.6 causing crash due to PR #1419

5 participants