PollingConditions java.lang.IllegalArgumentException: timeout value is negative

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Patrick Bray

Hi All, 

I have recently seen an issue where I received an IllegalArgumentException from PollingConditions. 

def conditions = new PollingConditions(timeout: 60, initialDelay: 1, delay: 2, factor: 1.25)

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: timeout value is negative
java
.lang.IllegalArgumentException: timeout value is negative
at spock
.util.concurrent.PollingConditions.within(PollingConditions.java:166)
at spock
.util.concurrent.PollingConditions.eventually(PollingConditions.java:134)

Thread.sleep(Math.min(currDelay, start + timeoutMillis - System.currentTimeMillis()));

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?

Let me know if you agree and I will look at raising a PR.  

Thanks,
Patrick Bray 

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Peter Niederwieser
Administrator

On 22 Dec 2014, at 01:11, Patrick Bray <[hidden email]> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Luke Daley-2
I’ve seen this when stopping at breakpoints.


On 23 December 2014 at 12:47:32 am, [hidden email] ([hidden email]) wrote:


On 22 Dec 2014, at 01:11, Patrick Bray <[hidden email]> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

Cheers,
Peter
--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

David Kowis
In reply to this post by Peter Niederwieser


On Monday, December 22, 2014 at 8:47:32 AM UTC-6, Peter Niederwieser wrote:

On 22 Dec 2014, at 01:11, Patrick Bray <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="KSar-feje7QJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">patric...@...> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

I've been able to reproduce it every time reliably with this:
https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962

It appears that if the work takes longer than it's polling interval, you end up barfing the loop pretty much immediately. We're running into it with some of our existing tests that are doing work with JMX, and it's taking longer than the loop interval to execute.

Thanks,
David Kowis


 

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Peter Niederwieser
Administrator
Thanks for the reproducible example. Would you mind filing an issue at http://issues.spockframework.org?

Cheers,
Peter

On 20 Jan 2015, at 16:38, David Kowis <[hidden email]> wrote:



On Monday, December 22, 2014 at 8:47:32 AM UTC-6, Peter Niederwieser wrote:

On 22 Dec 2014, at 01:11, Patrick Bray <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="KSar-feje7QJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" class="">patric...@...> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

I've been able to reproduce it every time reliably with this:
https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962

It appears that if the work takes longer than it's polling interval, you end up barfing the loop pretty much immediately. We're running into it with some of our existing tests that are doing work with JMX, and it's taking longer than the loop interval to execute.

Thanks,
David Kowis


 

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

David Kowis


On Tue, Jan 20, 2015 at 9:45 AM, [hidden email] <[hidden email]> wrote:
Thanks for the reproducible example. Would you mind filing an issue at http://issues.spockframework.org?

 

Cheers,
Peter

On 20 Jan 2015, at 16:38, David Kowis <[hidden email]> wrote:



On Monday, December 22, 2014 at 8:47:32 AM UTC-6, Peter Niederwieser wrote:

On 22 Dec 2014, at 01:11, Patrick Bray <[hidden email]> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

I've been able to reproduce it every time reliably with this:
https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962

It appears that if the work takes longer than it's polling interval, you end up barfing the loop pretty much immediately. We're running into it with some of our existing tests that are doing work with JMX, and it's taking longer than the loop interval to execute.

Thanks,
David Kowis


 

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Dan
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Dan
Any solution to this yet?

On Tuesday, January 20, 2015 at 11:11:36 AM UTC-5, David Kowis wrote:


On Tue, Jan 20, 2015 at 9:45 AM, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">pnie...@... <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">pnie...@...> wrote:
Thanks for the reproducible example. Would you mind filing an issue at <a href="http://issues.spockframework.org?" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fissues.spockframework.org%3F\46sa\75D\46sntz\0751\46usg\75AFQjCNHfHkARBowxzXUATnYwFuNhuqY_YA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fissues.spockframework.org%3F\46sa\75D\46sntz\0751\46usg\75AFQjCNHfHkARBowxzXUATnYwFuNhuqY_YA';return true;">http://issues.spockframework.org?

Filed: <a href="https://code.google.com/p/spock/issues/detail?id=383" target="_blank" rel="nofollow" onmousedown="this.href='https://code.google.com/p/spock/issues/detail?id\075383';return true;" onclick="this.href='https://code.google.com/p/spock/issues/detail?id\075383';return true;">https://code.google.com/p/spock/issues/detail?id=383

Thanks!
 

Cheers,
Peter

On 20 Jan 2015, at 16:38, David Kowis <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">dko...@...> wrote:



On Monday, December 22, 2014 at 8:47:32 AM UTC-6, Peter Niederwieser wrote:

On 22 Dec 2014, at 01:11, Patrick Bray <[hidden email]> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

I've been able to reproduce it every time reliably with this:
<a href="https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fdkowis%2F3b5af9fa6bafdd7aa962\46sa\75D\46sntz\0751\46usg\75AFQjCNH3yu00r5kr_B2lvYFeQAG0_UD1Xg';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fdkowis%2F3b5af9fa6bafdd7aa962\46sa\75D\46sntz\0751\46usg\75AFQjCNH3yu00r5kr_B2lvYFeQAG0_UD1Xg';return true;">https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962

It appears that if the work takes longer than it's polling interval, you end up barfing the loop pretty much immediately. We're running into it with some of our existing tests that are doing work with JMX, and it's taking longer than the loop interval to execute.

Thanks,
David Kowis


 

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">spockframewor...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">spockfr...@googlegroups.com.
Visit this group at <a href="http://groups.google.com/group/spockframework" target="_blank" rel="nofollow" onmousedown="this.href='http://groups.google.com/group/spockframework';return true;" onclick="this.href='http://groups.google.com/group/spockframework';return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">spockframewor...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n7fgdBP5aZYJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">spockfr...@googlegroups.com.
Visit this group at <a href="http://groups.google.com/group/spockframework" target="_blank" rel="nofollow" onmousedown="this.href='http://groups.google.com/group/spockframework';return true;" onclick="this.href='http://groups.google.com/group/spockframework';return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PollingConditions java.lang.IllegalArgumentException: timeout value is negative

Leonard Brünings
It is not fixed yet, the problem is in https://github.com/spockframework/spock/blob/master/spock-core/src/main/java/spock/util/concurrent/PollingConditions.java Line 166

> Thread.sleep(Math.min(currDelay, start + timeoutMillis - System.currentTimeMillis()));

As David said, the problem is if the closure takes longer to execute than the interval the second term will be negative and cause the exception.

An easy fix is this

> Thread.sleep(Math.max(0, Math.min(currDelay, start + timeoutMillis - System.currentTimeMillis())));

this would prevent it from becoming negative, another way would be to have a configurable minimum delay

> Thread.sleep(Math.max(minDelay, Math.min(currDelay, start + timeoutMillis - System.currentTimeMillis())));

Maybe Peter can weigh in on what would be the best solution.

Cheers
Leonard

On Thursday, April 9, 2015 at 4:02:11 AM UTC+2, Dan wrote:
Any solution to this yet?

On Tuesday, January 20, 2015 at 11:11:36 AM UTC-5, David Kowis wrote:


On Tue, Jan 20, 2015 at 9:45 AM, [hidden email] <[hidden email]> wrote:
Thanks for the reproducible example. Would you mind filing an issue at <a href="http://issues.spockframework.org?" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fissues.spockframework.org%3F\46sa\75D\46sntz\0751\46usg\75AFQjCNHfHkARBowxzXUATnYwFuNhuqY_YA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fissues.spockframework.org%3F\46sa\75D\46sntz\0751\46usg\75AFQjCNHfHkARBowxzXUATnYwFuNhuqY_YA';return true;">http://issues.spockframework.org?

Filed: <a href="https://code.google.com/p/spock/issues/detail?id=383" rel="nofollow" target="_blank" onmousedown="this.href='https://code.google.com/p/spock/issues/detail?id\075383';return true;" onclick="this.href='https://code.google.com/p/spock/issues/detail?id\075383';return true;">https://code.google.com/p/spock/issues/detail?id=383

Thanks!
 

Cheers,
Peter

On 20 Jan 2015, at 16:38, David Kowis <[hidden email]> wrote:



On Monday, December 22, 2014 at 8:47:32 AM UTC-6, Peter Niederwieser wrote:

On 22 Dec 2014, at 01:11, Patrick Bray <[hidden email]> wrote:

I am guessing that (start + timeoutMillis - System.currentTimeMillis()) is negative in this case and that this would have exhausted the timeout but it might be nicer to catch this scenario and raise the appropriate SpockTimeoutError?


Any ideas how this could ever happen?

I've been able to reproduce it every time reliably with this:
<a href="https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fdkowis%2F3b5af9fa6bafdd7aa962\46sa\75D\46sntz\0751\46usg\75AFQjCNH3yu00r5kr_B2lvYFeQAG0_UD1Xg';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Fdkowis%2F3b5af9fa6bafdd7aa962\46sa\75D\46sntz\0751\46usg\75AFQjCNH3yu00r5kr_B2lvYFeQAG0_UD1Xg';return true;">https://gist.github.com/dkowis/3b5af9fa6bafdd7aa962

It appears that if the work takes longer than it's polling interval, you end up barfing the loop pretty much immediately. We're running into it with some of our existing tests that are doing work with JMX, and it's taking longer than the loop interval to execute.

Thanks,
David Kowis


 

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/spockframework" rel="nofollow" target="_blank" onmousedown="this.href='http://groups.google.com/group/spockframework';return true;" onclick="this.href='http://groups.google.com/group/spockframework';return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/spockframework" rel="nofollow" target="_blank" onmousedown="this.href='http://groups.google.com/group/spockframework';return true;" onclick="this.href='http://groups.google.com/group/spockframework';return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.