-
Notifications
You must be signed in to change notification settings - Fork 117
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
Thread safe improvements on OIDCDiscoveryConfigListener #4159
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4159 +/- ##
=======================================
Coverage 45.51% 45.51%
=======================================
Files 270 270
Lines 19925 19925
=======================================
Hits 9069 9069
Misses 10129 10129
Partials 727 727 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Matthias Wessendorf <[email protected]>
...n/java/dev/knative/eventing/kafka/broker/receiver/impl/auth/OIDCDiscoveryConfigListener.java
Show resolved
Hide resolved
.forEach(c -> c.accept(this.oidcDiscoveryConfig)); | ||
OIDCDiscoveryConfig config = this.oidcDiscoveryConfig.get(); | ||
if (config != null) { | ||
this.callbacks.forEach(callback -> callback.accept(config)); |
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 see in deregisterCallback
we set callback
(the element) to null, don't we need to check that callback
is not null before calling accept
?
this.callbacks = new ArrayList<>(); | ||
} | ||
|
||
public synchronized int registerCallback(Consumer<OIDCDiscoveryConfig> callback) { |
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.
One other issue I see with index based registration is that with addition and removal of callbacks the array is ever growing (and therefore a memory leak), which can lead to OOM, it's better to have a map id -> callback
so that we can remove elements during registration rather than setting them to null
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.
you mean like ConcurrentMap
? instead of the CopyOnWriteArrayList
?
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.
yes
Signed-off-by: Matthias Wessendorf <[email protected]>
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: matzew, pierDipi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherry-pick release-1.16 |
@matzew: once the present PR merges, I will cherry-pick it on top of In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/cherry-pick release-1.15 |
@matzew: once the present PR merges, I will cherry-pick it on top of In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/retest |
@matzew: new pull request created: #4160 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@matzew: new pull request created: #4161 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Proposed Changes
ConcurrentHashMap
,AtomicRef
andAtomicInt
for improving thread safenessRelease Note
Docs