Skip to content

Resolves #699 Intermittent failure was due to Thread.sleep in the code #802

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

Merged
merged 1 commit into from
Oct 21, 2018

Conversation

npathai
Copy link
Contributor

@npathai npathai commented Oct 15, 2018

Resolves #699

While performing unit test cases there was race condition between two threads, so it was not guaranteed to work every time. Used an interface DelayProvider for simulating delay, and while unit testing fake delay provider is used that eradicates the use of Threads in unit test cases, which is not a good practice.

This issue could also have been resolved by increasing the Thread.sleep(50) interval to higher value, but being design patterns repository I opted for better approach of not using threads when unit testing, due to complication of unit testing.

  • Update class diagram if needed. DelayProvider is an internal class so I am not sure if we should incorporate it in class diagram
  • Do we have a better name than DelayProvider?

…rming unit test cases there was race condition between two threads, so it was not guaranteed to work every time. Used an interface DelayProvider for simulating delay, and while unit testing fake delay provider is used that eradicates the use of Threads in unit test cases, which is not a good practice.
@npathai npathai changed the title #699 Intermittent failure was due to Thread.sleep in the code Resolves #699 Intermittent failure was due to Thread.sleep in the code Oct 15, 2018
Copy link

@IAmPramod IAmPramod left a comment

Choose a reason for hiding this comment

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

Looks good.

@iluwatar
Copy link
Owner

Looks good to me as well. I don't think we need to modify the class diagram because of adding the internal DelayProvider. It's a nice abstraction and makes the code look cleaner 👍 Well done for resolving this long outstanding issue @npathai

@iluwatar iluwatar merged commit f5eaf06 into master Oct 21, 2018
@iluwatar iluwatar deleted the Issue#699 branch December 30, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent failure in Balking pattern
3 participants