Skip to content

simplify BlockingProcessStreamReader; fix tests#1457

Merged
garrettjonesgoogle merged 1 commit intogoogleapis:masterfrom
pongad:stream-reader
Dec 8, 2016
Merged

simplify BlockingProcessStreamReader; fix tests#1457
garrettjonesgoogle merged 1 commit intogoogleapis:masterfrom
pongad:stream-reader

Conversation

@pongad
Copy link
Contributor

@pongad pongad commented Dec 8, 2016

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.

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.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 8, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 83.577% when pulling fca0cfe on pongad:stream-reader into cacf65e on GoogleCloudPlatform:master.

@garrettjonesgoogle garrettjonesgoogle merged commit 614cbe4 into googleapis:master Dec 8, 2016
@pongad pongad deleted the stream-reader branch December 12, 2016 03:33
github-actions bot pushed a commit that referenced this pull request Sep 15, 2022
meltsufin pushed a commit that referenced this pull request Dec 22, 2025
chingor13 pushed a commit that referenced this pull request Jan 6, 2026
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
chingor13 pushed a commit that referenced this pull request Jan 22, 2026
…etParent (#1457)

* fix: set database ID on parent key

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
chingor13 pushed a commit that referenced this pull request Jan 22, 2026
🤖 I have created a release *beep* *boop*
---


## [2.20.0](https://togithub.com/googleapis/java-datastore/compare/v2.19.3...v2.20.0) (2024-05-27)


### Features

* New PropertyMask field which allows partial commits, lookups, and query results ([#1455](https://togithub.com/googleapis/java-datastore/issues/1455)) ([ff5e397](https://togithub.com/googleapis/java-datastore/commit/ff5e39775446216b4806f55f14dacb7fc8e8854b))


### Bug Fixes

* Migrate off TextPrinter's deprecated methods ([#1452](https://togithub.com/googleapis/java-datastore/issues/1452)) ([c3c1317](https://togithub.com/googleapis/java-datastore/commit/c3c131735863d71971110e2ac7ac0244ce16ee92))
* Set the correct database id on the key parent when calling Key#getParent ([#1457](https://togithub.com/googleapis/java-datastore/issues/1457)) ([992815d](https://togithub.com/googleapis/java-datastore/commit/992815d9989d04f7b371dfa320ed17894626a07f))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
chingor13 pushed a commit that referenced this pull request Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants