BaseEncoding.encodingStream().close() is non-idempotent

Open Beginner friendly
#5,284 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
api

Research direction

Start at BaseEncoding.encodingStream() and reproduce the issue with the StringWriter and OutputStream sequence shown in the report. Trace the close behavior and verify that calling close() a second time leaves the writer unchanged, while the existing encoding output still remains correct.

Written by the indexing model from the issue text.

Description

P3 package=io type=defect

Closeable.close says:

If the stream is already closed then invoking this method has no effect.

Code:

StringWriter w = new StringWriter();
OutputStream out = BaseEncoding.base64().encodingStream(w);
out.write(0);
out.close();
System.out.println(w);
out.close();
System.out.println(w);

Output:

AA==
AA==A===
Dominant language
Java
Stars
51.9k
Forks
11.2k
Avg merge
2h 38m
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/guava

All issues in google/guava

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.