-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[WIP] 7037 Abstract BlockingQueue#Offer Failure Handling #7052
[WIP] 7037 Abstract BlockingQueue#Offer Failure Handling #7052
Conversation
if (!success) { | ||
log.warn("queue too slow!"); | ||
} | ||
statusQueueHelper.offerAndHandleFailure( |
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.
In the current form BlockingQueueHelper
only increases the complexity of classes where it is used. It's too shallow.
I doubt it's reasonable to extract the pattern from all places across the codebase where it was found. What about abstracting it just in emitters? See #7057.
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.
Makes sense. I noticed the behaviour was fairly different between the provided examples so I used this abstraction to avoid changing behaviour. Does it make sense to close this issue/PR and focus on #7057?
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 think so.
Addresses: #7037
To abstract the logic of checking whether a
BlockingQueue#offer()
call succeeded, I created a helper class that wraps theoffer
call and executes a function (provided as an argument) if unsuccessful. I chose to implement the abstraction this way instead of a utility class with static methods so that the type of the offered element could be validated at compile time.