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
Copy Markdown
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
Copy Markdown

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
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 11, 2026
chingor13 pushed a commit that referenced this pull request Mar 12, 2026
lqiu96 pushed a commit that referenced this pull request Mar 20, 2026
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
meltsufin pushed a commit that referenced this pull request Apr 29, 2026
…ncy-plugin to v3.5.0 - abandoned (#1457)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.apache.maven.plugins:maven-dependency-plugin](https://maven.apache.org/plugins/) | `3.4.0` -> `3.5.0` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/compatibility-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/confidence-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43My4zIiwidXBkYXRlZEluVmVyIjoiMzQuOTcuNiJ9-->
meltsufin pushed a commit that referenced this pull request May 1, 2026
…ncy-plugin to v3.5.0 - abandoned (#1457)

[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.apache.maven.plugins:maven-dependency-plugin](https://maven.apache.org/plugins/) | `3.4.0` -> `3.5.0` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/compatibility-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-dependency-plugin/3.5.0/confidence-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43My4zIiwidXBkYXRlZEluVmVyIjoiMzQuOTcuNiJ9-->
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