-
Notifications
You must be signed in to change notification settings - Fork 229
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: quotaProjectId should be applied for cached getRequestMetadata(URI, Executor, RequestMetadataCallback)
#509
Conversation
oauth2_http/javatests/com/google/auth/oauth2/UserCredentialsTest.java
Outdated
Show resolved
Hide resolved
oauth2_http/javatests/com/google/auth/oauth2/UserCredentialsTest.java
Outdated
Show resolved
Hide resolved
…d and other headers
Codecov Report
@@ Coverage Diff @@
## master #509 +/- ##
============================================
+ Coverage 79.80% 79.91% +0.11%
- Complexity 409 413 +4
============================================
Files 28 28
Lines 1936 1947 +11
Branches 201 203 +2
============================================
+ Hits 1545 1556 +11
Misses 283 283
Partials 108 108
Continue to review full report at Codecov.
|
getRequestMetadata(URI, Executor, RequestMetadataCallback)
@@ -154,7 +156,9 @@ public void refresh() throws IOException { | |||
synchronized (lock) { | |||
requestMetadata = null; | |||
temporaryAccess = null; | |||
useAccessToken(Preconditions.checkNotNull(refreshAccessToken(), "new access token")); | |||
useAccessToken( | |||
Preconditions.checkNotNull(refreshAccessToken(), "new access token"), |
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 a very strange and possibly inappropriate use of Preconditions.
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.
I agree, it's been there for years.
Filed #510 to track.
/** | ||
* Provide additional headers to return as request metadata. | ||
* | ||
* @return Map of additional headers. |
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.
nit: "map of additional headers" or just "additional headers" since the map is provided by the type
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.
Changed to "additional headers"
@@ -56,6 +57,7 @@ | |||
|
|||
private static final long serialVersionUID = 4556936364828217687L; | |||
private static final long MINIMUM_TOKEN_MILLISECONDS = 60000L * 5L; | |||
private static final Map<String, List<String>> EMPTY_EXTRA_HEADERS = Collections.emptyMap(); |
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.
will this be added to by subclasses? I'm not quite following but it looks like it might be; but this is immutable.
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.
addQuotaProjectIdToRequestMetadata
returns a new ImmutableMap
so nothing should be added to this (nor do we want anyone to).
* | ||
* @return Map of additional headers. | ||
*/ | ||
protected Map<String, List<String>> getAdditionalHeaders() { |
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.
nested types (Map of List) suggest there's a missed opportunity for a more semantic class.
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.
HTTP headers behave as maps of String
s to a list of String
s. We could possible wrap it, but we're not adding any extra behavior. For a general purpose HTTP client, we might do so, but it seem unnecessary here.
Note: getRequestMetadata()
does return this same type (but we really can't feasibly change that as everything that depends on google-auth-library expects that return type).
🤖 I have created a release \*beep\* \*boop\* --- ### [0.22.2](https://www.github.com/googleapis/google-auth-library-java/compare/v0.22.1...v0.22.2) (2020-12-11) ### Bug Fixes * quotaProjectId should be applied for cached `getRequestMetadata(URI, Executor, RequestMetadataCallback)` ([#509](https://www.github.com/googleapis/google-auth-library-java/issues/509)) ([0a8412f](https://www.github.com/googleapis/google-auth-library-java/commit/0a8412fcf9de4ac568b9f88618e44087dd31b144)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Refactors the injection of the quota project id (and possibly other future headers) into the entrypoint that caches the request metadata (in OAuth2Credentials).
Fixes #507