Skip to content
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

Conversation

justinborromeo
Copy link
Contributor

Addresses: #7037

To abstract the logic of checking whether a BlockingQueue#offer() call succeeded, I created a helper class that wraps the offer 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.

@justinborromeo justinborromeo changed the title 7037 Abstract BlockingQueue#Offer Failure Handling [WIP] 7037 Abstract BlockingQueue#Offer Failure Handling Feb 12, 2019
@gianm gianm added the WIP label Feb 12, 2019
if (!success) {
log.warn("queue too slow!");
}
statusQueueHelper.offerAndHandleFailure(
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

@justinborromeo justinborromeo deleted the 7037-Abstract-Away-BlockingQueueOffer branch February 13, 2019 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants