Skip to content

Remove package private BitStream and use BitInputStream directly instead - #817

Open
fkjellberg wants to merge 1 commit into
apache:masterfrom
fkjellberg:refactor-bitstream
Open

fkjellberg wants to merge 1 commit into
apache:masterfrom
fkjellberg:refactor-bitstream

Conversation

@fkjellberg

Copy link
Copy Markdown
Contributor

Thanks for your contribution to Apache Commons! Your help is appreciated!

Before you push a pull request, review this list:

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. I used Claude Opus 5.5 for code analysis, code review and docs.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

Remove the package private BitStream class, which only ExplodingInputStream used, and use BitInputStream directly instead.

API change

  • Adds BitInputStream.readByte() to the public API. It reads the next 8 bits from the stream and returns them as an int in range 0 to 255. It replaces BitStream.nextByte().

Other changes

  • BZip2CompressorInputStream and ExplodingInputStream call readByte() instead of readBits(8) or nextByte().
  • BitStream.nextBits(int) is removed and its caller uses readBits(int) instead. nextBits threw an exception when asked for more than 8 bits. Its only caller asks for 6 or 7 bits, depending on the dictionary size, so the check was never triggered.
  • Added tests for the new method in BitInputStreamTest.

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

Successfully merging this pull request may close these issues.

1 participant