-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Handles possible heap data corruption of OAuth2Util.AuthSession#headers
#10615
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
Conversation
| .tokenType(response.issuedTokenType()) | ||
| .build(); | ||
| this.headers = RESTUtil.merge(headers, authHeaders(config.token())); | ||
| synchronized (lock) { |
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.
Maybe just a simple
| synchronized (lock) { | |
| synchronized (this) { |
?
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.
TBH I'm not convinced that a lock solves a real problem. In practice, this method cannot be called concurrently, therefore just dissociating reading the field and writing the field back is enough to clarify the intents here:
Map<String, String> headers = this.headers;
this.headers = RESTUtil.merge(headers, authHeaders(config.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.
@snazy @adutra thanks so much for reviewing
Maybe just a simple?
@snazy I just wanna avoid using synchronized on class. See: https://stackoverflow.com/questions/442564/avoid-synchronizedthis-in-java
TBH I'm not convinced that a lock solves a real problem. In practice, this method cannot be called concurrently, therefore just dissociating reading the field and writing the field back is enough to clarify the intents here:
@adutra "this method cannot be called concurrently" - could you explain why, pls? The RESTUtil.merge(...) function read a volatile variable (headers), so I think synchronized might make sense here.
|
@tlm365
|
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 with @adutra , I don't think a lock is necessary here. You can just read the volatile value into a temporary variable and use that temporary variable when merging and assign that to the field.
|
@adutra @amogh-jahagirdar thanks for reviewing, I've updated it. |
core/src/main/java/org/apache/iceberg/rest/auth/OAuth2Util.java
Outdated
Show resolved
Hide resolved
…#headers Signed-off-by: Tai Le Manh <manhtai.lmt@gmail.com>
amogh-jahagirdar
left a comment
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.
Thanks @tlm365 I will merge when checks pass.
…headers (apache#10615) Signed-off-by: Tai Le Manh <manhtai.lmt@gmail.com>
…headers (apache#10615) Signed-off-by: Tai Le Manh <manhtai.lmt@gmail.com>
Closes #10591.