Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed JSON: java.io.IOException: Pipe broken #1

Closed
ianparkinson opened this issue Mar 11, 2023 · 1 comment
Closed

Malformed JSON: java.io.IOException: Pipe broken #1

ianparkinson opened this issue Mar 11, 2023 · 1 comment

Comments

@ianparkinson
Copy link
Owner

Occasionally, helog fails with:

Malformed JSON: java.io.IOException: Pipe broken

(Or, when --raw is specified, just Pipe broken)

I've only noticed this when multiple instances of helog are running, and they all fail at the same time.

@ianparkinson
Copy link
Owner Author

ianparkinson commented Mar 11, 2023

helog uses a PipedReader/PipedWriter pair to conveniently shepherd text from the WebSocket.Listener to a separate thread running gson.fromJson() (which blocks).

According to javadoc for the related PipedInputStream:

A pipe is said to be broken if a thread that was providing data bytes to the connected piped output stream is no longer alive.

...and I can see in the source for PipedReader that, on read, it checks whether the last thread that wrote to the PipedWriter is still alive, and fails with Pipe broken if not. Meanwhile WebSocket doesn't guarantee that it will always call the listener using the same thread (and nor should it).

That doesn't entirely explain why multiple runs all fail simultaneously, but presumably there's some OS-level socket dispatching going on.

ianparkinson added a commit that referenced this issue Mar 11, 2023
Also, --raw now remembers to check for expected problems in this case.

See #1.
ianparkinson added a commit that referenced this issue Mar 12, 2023
Used to ferry text from the WebSocket listener to a Reader passed to GSON. Unlike PipedReader/PipedWriter, this implementation tolerates the death of the thread used by WebSocket.

Fixes #1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant