Avoid sending too many metrics to a closed socket, to avoid a race
condition with the lastException reset.
Occasionally, two metrics will be sent to the client after the server
socket was removed. First one triggers an exception and causes the
send loop to break. Test case then resets the lastException variable,
while the client is still running and has another message buffered. If
that is delivered before the server is started, it triggers another
exception and causes nullValue() check to fail and the end of the test
case.
Avoid sending too many metrics to a closed socket, to avoid a race condition with the lastException reset.
Occasionally, two metrics will be sent to the client after the server socket was removed. First one triggers an exception and causes the send loop to break. Test case then resets the lastException variable, while the client is still running and has another message buffered. If that is delivered before the server is started, it triggers another exception and causes nullValue() check to fail and the end of the test case.