-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify BlockingProcessStreamReader; fix tests
Update #1429. This commit simplifies the main run() method. Previous implementation checks whether the underlying Reader is ready to read then either reads a line or sleeps, catching InterruptedException to watch for any thread interruption. There are subtle difficulties with this approach: - Even if the underlying Reader is ready to read, it might not have enough bytes to form a line. It might still block. - It's not necessary to sleep. If the thread is interrupted while reading. It should throw InterruptedIOException. The method now reads in a loop, waiting for either exceptions or EOF. The test class implements a mock Logger that logs to a data structure. It then verifies that the data structure holds appropriate logs. As implemented, this can cause a race, as two threads, the writer and the verifier, run concurrently. This commit fixes this by waiting for the writing thread to terminate before verifying.
- Loading branch information
Showing
2 changed files
with
12 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters