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

Versions newer than 1.32.0 report wrong version in User-Agent on Android #892

Closed
abelthefirst opened this issue Nov 21, 2019 · 6 comments · Fixed by #919
Closed

Versions newer than 1.32.0 report wrong version in User-Agent on Android #892

abelthefirst opened this issue Nov 21, 2019 · 6 comments · Fixed by #919
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. semver: patch A minor bug fix or small change. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@abelthefirst
Copy link

I'm using 1.33.0, but the version reported is 0.0.

User-Agent: Google-HTTP-Java-Client/0.0 (gzip)

The reason is the implementation of the BaseDexClassLoader.getPackage(String name) - https://android.googlesource.com/platform/libcore/+/refs/heads/master/dalvik/src/main/java/dalvik/system/BaseDexClassLoader.java#305

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Nov 22, 2019
@elharo
Copy link
Contributor

elharo commented Nov 25, 2019

did you mean newer than 1.32.0? If it's older, upgrading is a fix.

@elharo elharo added priority: p2 Moderately-important priority. Fix may not be included in next release. semver: patch A minor bug fix or small change. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 25, 2019
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Nov 25, 2019
@abelthefirst abelthefirst changed the title Versions older than 1.32.0 report wrong version in User-Agent on Android Versions newer than 1.32.0 report wrong version in User-Agent on Android Nov 25, 2019
@abelthefirst
Copy link
Author

did you mean newer than 1.32.0? If it's older, upgrading is a fix.

You're right, I fixed the title, sorry for the confusion.

@elharo
Copy link
Contributor

elharo commented Nov 25, 2019

https://github.com/googleapis/google-api-java-client/pull/1425/files might be related

@abelthefirst Can you reproduce this using only google-http-java-client? Any chance this is coming from some other library (where we made recent changes around this header)

@elharo
Copy link
Contributor

elharo commented Nov 25, 2019

#806 is probably the culprit

@elharo
Copy link
Contributor

elharo commented Nov 25, 2019

suspect we can change

private static String getVersion() {
...
    if (version == null) {

to

private static String getVersion() {
    String version = HttpRequest.class.getPackage().getImplementationVersion();
    // in a non-packaged environment (local), there's no implementation version to read
    if (version == null || "0.0".equals(version)) {

but I need a test case first.

@elharo
Copy link
Contributor

elharo commented Nov 26, 2019

This may also be failing in GAX

chingor13 pushed a commit that referenced this issue Dec 17, 2019
The original implementation of `getVersion` used the implementation
version of the package of the declaring class, however there is
differing behavior between Android and openjdk based jvms.

In order to be consistent across platforms we will now always resolve
the value from the `google-http-client.properties` file that is
generated during the build. This method should be stable as it based
on loading a classpath resource which has cross jvm support.

Fixes #892
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. semver: patch A minor bug fix or small change. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants