reactive-streams / reactive-streams-dotnet

Reactive Streams for .NET
MIT No Attribution
199 stars 28 forks source link

ArgumentOutOfRangeException with a TimeSpan value #35

Closed akarnokd closed 7 years ago

akarnokd commented 7 years ago

Randomly I'm getting the following ArgumentOutOfRangeException complaining about a negative TimeSpan value:

Test Name:  Required_spec102_maySignalLessThanRequestedAndTerminateSubscription
Test FullName:  Reactive4.NET.Test.DirectProcessor1Tck.Required_spec102_maySignalLessThanRequestedAndTerminateSubscription
Test Source:     : line 0
Test Outcome:   Failed
Test Duration:  0:00:00,126

Result StackTrace:  
a következő helyen: System.Collections.Concurrent.BlockingCollection`1.ValidateTimeout(TimeSpan timeout)
   a következő helyen: System.Collections.Concurrent.BlockingCollection`1.TryTake(T& item, TimeSpan timeout)
   a következő helyen: Reactive.Streams.TCK.Receptacle`1.Next(Int64 timeoutMilliseconds, String errorMessage)
   a következő helyen: Reactive.Streams.TCK.Receptacle`1.NextN(Int64 elements, Int64 timeoutMilliseconds, String errorMessage)
   a következő helyen: Reactive.Streams.TCK.ManualSubscriber`1.NextElements(Int64 elements, Int64 timeoutMilliseconds, String errorMessage)
   a következő helyen: Reactive.Streams.TCK.ManualSubscriber`1.NextElements(Int64 elements)
   a következő helyen: Reactive.Streams.TCK.PublisherVerification`1.<Required_spec102_maySignalLessThanRequestedAndTerminateSubscription>b__24_0(IPublisher`1 publisher)
   a következő helyen: Reactive.Streams.TCK.PublisherVerification`1.ActivePublisherTest(Int64 elements, Boolean completionSignalRequired, Action`1 run)
   a következő helyen: Reactive.Streams.TCK.PublisherVerification`1.Required_spec102_maySignalLessThanRequestedAndTerminateSubscription()
Result Message: 
System.ArgumentOutOfRangeException : A megadott időkorlátnak egy -1 és 2147483647 közötti értéknek kell lennie, a határokat is beleértve.
Paraméter neve: timeout
Az aktuális érték: -00:00:00.0580000.

The Hungarian error message translates as: the timeout value must be between -1 and 2147483647 inclusive but it was -58.

marcpiechura commented 7 years ago

I was able to reproduce it locally, you need to increase the timeout for your DirectProcessor1Tck tests, 100 ms worked for me. Will create a PR that creates a more meaningful error message.

akarnokd commented 7 years ago

I haven't looked into the TCK code but I'd assume there is an arithmetic operation on a TimeSpan done inside the TCK that ends up negative because of the late response of the DirectProcessor1Tck, right?

marcpiechura commented 7 years ago

yes and we use this result as timeout for the call to the blocking collection.