Skip to content

Improve OutputStream and Writer emulation #10119

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zbynek
Copy link
Collaborator

@zbynek zbynek commented Apr 27, 2025

Fixes #10123

Add a few convenience methods introduced in Java 11.

nullStream.close();
try {
nullStream.write(1);
fail("Writing to a closed stream should fail.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting perhaps that StringReader ignores close, and would fail this style of test. This goes against the JRE implementation and javadoc. There may be others that are wrong too.

public void close() throws IOException { }

Definitely not asking for this to be fixed here, just noting it.

Comment on lines +256 to +258
assertThrows(IOException.class, () -> nullWriter.write(42));
assertThrows(IOException.class, () -> nullWriter.append('a'));
assertThrows(IOException.class, () -> nullWriter.append("hola", 1, 2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look wrong to me - why should they throw? Should these be later in the test, perhaps after a nullWriter.close()?

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

Successfully merging this pull request may close these issues.

OutputStream, ByteArrayOutputStream and Writer emulation
2 participants