-
Notifications
You must be signed in to change notification settings - Fork 78
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
Rework 5s sleep with 100ms intervals #233
Conversation
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.
Of course the best solution would be to find some method that blocks until the log handlers have executed and flushed their output, but this is certainly a more efficient workaround than the hasty five-second sleep I added the other day.
FWIW on linux the test took less than 1s and on windows around 2s |
String text = FileUtils.readFileToString(logFile, StandardCharsets.UTF_8); | ||
// check the log file every 100ms for 5s | ||
String text = ""; | ||
for(int i=0; i < 50; ++i) { |
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.
the idea of a loop should be to wait a certain time until reaching a conditon (it;s a fragile 5s timeout with such loop)
if you don't want to do it manually this can be easily achieved using http://www.awaitility.org/
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.
Well, if we are going to be expounding our opinions about how to solve this problem in the most perfect way possible, which is what we seem to be doing, then I think the best solution would be to block until the log handler is flushed. That would eliminate the need for any fragile busy-waiting in the first place.
You can see my sketch in #219 for an example of how to do synchronization between JUL and application code. While it is a bit tricky to understand at first, once you spend a few minutes stepping through JUL in a debugger and understand the basic code flow it all starts to make sense.
Of course, I already approved this change, and I personally feel the current PR is good enough, but if others feel that blocking this PR is a productive way to engage with a first-time contributor, far be it from me to stand in the way of that.
I believe the above post was polite, technical, and community-oriented.
in this case we will rely on default surefire timeout which is very long. We can eventually move the timeout to a higher value (10s) and assume if the content has not been written to the file there is a regression
I guess when proposing a PR. The contributor is asking review on how to eventually improve his change. The check could be simply reduce to:
and obviously adding the dependency pom:
The goal of my comment is to propose an improvement which should be the goal of any PR's comment. |
Not necessarily:
Introducing a new library also has its own maintenance costs, though I am OK with Awaitility.
You and I must have different definitions of "review" and "improvement". When your first reaction to a pull request is to hit the big red "Request Changes" button without providing the reasoning (as you did in jenkinsci/pom#209 (review)), this can come across as heavy-handed. I wonder how the author of this PR would feel if I hit the big red "Request Changes" button and insisted on implementing the ideal solution of a custom log handler with perfect synchronization. Sure, it is strictly more efficient than busy-waiting. But it is also significantly more implementation effort for a negligible gain. If I were to do that, I might very well be called unreasonable. But suggesting it as optional feedback could very well be reasonable, since it leaves the choice up to the author. My personal experience has been that you tend to deny me the freedom to make my own judgments, for example regarding when it is safe to delete dead code. I used to work on OS kernel modules, so I know that some situations require complete and total rigor when it comes to correctness and synchronization. This minor test case is not one of them, in my opinion. As another contributor observed in jenkinsci/pipeline-stage-view-plugin#122 (comment), "your approach is very much in the minority of maintainers." But I respect that you have a different approach. I only hope that other contributors to this repository will not feel as discouraged as I have been by your code reviews. |
If you have any personal grief/attack to me please send me an email. |
anyway feel free to do whatever you want here. |
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.
no comment
Like you, I would much rather focus on technical topics and getting code merged.
Which is what the
I do not see what is fragile about the code the author has submitted. It seems perfectly correct to me. Sure, a few lines could be shaved off by introducing a new dependency on Awaitility, but I see no reason why that is significant enough to request changes. That seems like a matter of personal preference to me. If there is something incorrect about this submission that merits a blocking review, I am not seeing it. |
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Thanks! |
Thanks for the PR! |
Reworked Test case to check every 100ms and break out the loop once a response has been written to the log file.
Fixes #231