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 a team as a code owner February 15, 2021 22:46
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 15, 2021
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Feb 15, 2021
@thiagotnunes
Copy link
Contributor Author

cc @allenpradeep @mohanli-ml

@codecov
Copy link

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

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
@thiagotnunes thiagotnunes deleted the user-agent-header branch February 17, 2021 04:33
@@ -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

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

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

ansh0l pushed a commit to ansh0l/java-spanner that referenced this pull request Nov 10, 2022
This is an auto-generated regeneration of the .pb.go files by
cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will
update the corresponding PR to depend on the newer version of go-genproto, and
assign reviewers. Whilst this or any regen PR is open in go-genproto, genbot
will not create any more regeneration PRs. If all regen PRs are closed,
gapicgen will create a new set of regeneration PRs once per night.

If you have been assigned to review this PR, please:

- Ensure that CI is passing. If it's failing, it requires your manual attention.
- Approve and submit this PR if you believe it's ready to ship. That will prompt
genbot to assign reviewers to the google-cloud-go PR.

Corresponding google-cloud-go PR: googleapis/google-cloud-go#6467

Changes:

feat: add content of IP Utilization insights to Stackdriver logging proto for Network Analyzer
  PiperOrigin-RevId: 465110127
  Source-Link: googleapis/googleapis@2206a0f

chore: regenerate API index

  Source-Link: googleapis/googleapis@072a946

feat: Remove v1p4beta1 API protos. v1p4beta1 has been deprecated and announced through MSA. This is the cleanup
  PiperOrigin-RevId: 464897844
  Source-Link: googleapis/googleapis@73c7cd8
rajatbhatta pushed a commit to rajatbhatta/java-spanner that referenced this pull request Nov 17, 2022
The Statement#executeBatch() method did not respect the statement
timeout that had been set on a statement. This meant that a batch like
the following would always use the default timeout that is set in the
Gapic generated client, and ignore the timeout set in
Statement#setTimeout(int):

statement.setTimeout(120);
statement.addBatch("insert into foo (id) values (1)");
statement.executeBatch(); // This ignored the statement timeout

Fixes googleapis#870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting the user-agent with a header provider in SpannerOptions fails
4 participants