walmartlabs/mupd8 — pull request #38 by zheguang (2013-06-18 06:55:18+00:00)
Title: Issue35: Bugfix SourceReader initialization for sockets

Folks@Labs please make sure to run a product test under a normal workload. I've tested in automation with the new test cases in this patch. Thanks!

This patch implements a fix to the false-ngative bug tracked by https://github.com/walmartlabs/mupd8/issues/35.

The bug comes from the fact that the socket-type reader may be initialized to "None" if the source hasn't bound yet. So subsequent reads would always produce false-negative because the reconnection bit never gets executed.

This patch also introduces automated tests for the lazy binding source:
- SourceReader shouhld connect to a socket during initialization, retry until success.
- SourceReader should reconect to the socket if there was any exception during reads.

Note that some necessary code refactor is made to enable the stub/mock testing, which arguably entails better coding style.