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
fix: allows user-agent header with header provider #871
Conversation
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.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
LGTM |
google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java
Show resolved
Hide resolved
Tests if the default user agent is present in the user-agent header set in the GapicSpannerRpc class.
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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
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