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: allows user-agent header with header provider #871

Merged
merged 2 commits into from Feb 17, 2021

Conversation

thiagotnunes
Copy link
Contributor

@thiagotnunes thiagotnunes commented Feb 15, 2021

A bug was introduced, where if the caller tried to set a custom user agent with a header provider an exception would be thrown (for duplicate keys). Here, we merge the user agent set by the client along with the one set by the library, instead of throwing such exception.

Fixes #880

A bug was introduced, where if the caller tried to set a custom user
agent with a header provider an exception would be thrown (for duplicate
keys). Here, we merge the user agent set by the client along with the
one set by the library, instead of throwing such exception.
@thiagotnunes thiagotnunes requested a review from as a code owner Feb 15, 2021
@google-cla google-cla bot added the cla: yes label Feb 15, 2021
@product-auto-label product-auto-label bot added the api: spanner label Feb 15, 2021
@thiagotnunes thiagotnunes requested a review from olavloite Feb 15, 2021
@thiagotnunes
Copy link
Contributor Author

@thiagotnunes thiagotnunes commented Feb 15, 2021

@codecov
Copy link

@codecov codecov bot commented Feb 15, 2021

Codecov Report

Merging #871 (6ff8f44) into master (54cfa0f) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #871      +/-   ##
============================================
- Coverage     85.12%   85.10%   -0.02%     
- Complexity     2588     2590       +2     
============================================
  Files           143      143              
  Lines         14154    14156       +2     
  Branches       1366     1368       +2     
============================================
- Hits          12048    12047       -1     
- Misses         1537     1542       +5     
+ Partials        569      567       -2     
Impacted Files Coverage Δ Complexity Δ
...m/google/cloud/spanner/spi/v1/GapicSpannerRpc.java 81.89% <100.00%> (-0.20%) 83.00 <2.00> (+2.00) ⬇️
...m/google/cloud/spanner/connection/SpannerPool.java 87.36% <0.00%> (-0.53%) 33.00% <0.00%> (ø%)
...ain/java/com/google/cloud/spanner/SessionPool.java 89.05% <0.00%> (-0.20%) 72.00% <0.00%> (-1.00%)
...a/com/google/cloud/spanner/SessionPoolOptions.java 69.53% <0.00%> (ø) 17.00% <0.00%> (-1.00%)
...ud/spanner/SessionPoolAsyncTransactionManager.java 87.30% <0.00%> (+1.58%) 13.00% <0.00%> (+2.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54cfa0f...6ff8f44. Read the comment docs.

@mohanli-ml
Copy link
Contributor

@mohanli-ml mohanli-ml commented Feb 15, 2021

LGTM

Tests if the default user agent is present in the user-agent header set
in the GapicSpannerRpc class.
@thiagotnunes thiagotnunes merged commit 3de7e2a into googleapis:master Feb 17, 2021
18 of 19 checks passed
@thiagotnunes thiagotnunes deleted the user-agent-header branch Feb 17, 2021
@@ -494,6 +489,16 @@ public GapicSpannerRpc(final SpannerOptions options) {
}
}

private static HeaderProvider headerProviderWithUserAgentFrom(HeaderProvider headerProvider) {
final Map<String, String> headersWithUserAgent = new HashMap<>(headerProvider.getHeaders());
final String userAgent = headersWithUserAgent.get(USER_AGENT_KEY);
Copy link
Member

@meltsufin meltsufin Mar 13, 2021

Choose a reason for hiding this comment

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

@thiagotnunes user-agent and User-Agent should be equivalent.
This needs case insensitivity.

Copy link
Contributor Author

@thiagotnunes thiagotnunes May 10, 2021

Choose a reason for hiding this comment

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

Hey there, thanks for pointing this out.

This has been fixed in the following versions:

  1. 3.3.3
  2. 4.0.3
  3. 5.2.1
  4. 6.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants