hibri / HttpMock

A library for creating Http servers on the fly in tests and stubbing responses
MIT License
128 stars 44 forks source link

HttpServer: Fix IsAvailable() to be able to return FALSE #7

Closed knocte closed 11 years ago

knocte commented 11 years ago

If the method .Start() of HttpServer was not called, IsAvailable() was throwing an exception instead of returning FALSE.

This change has the added benefit that improves HttpMock a lot when run with Mono. Why? Because apparently the _thread.Start(); in Microsoft.NET is very fast and IsAvailable always was queried AFTER the server thread had already started Kayak. In Mono, this fast is not so fast, so then IsAvailable was throwing the exception and not using the retrying loop (that is already in place) properly.

This is not a Mono bug. When using multi-threading code, you should never assume any certain speed of any thread.

knocte commented 11 years ago

There was a typo in my commit message: "this fast" -> "this call"