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

Add FilterOutputStreamSlowMultibyteWrite #2024

Merged
merged 3 commits into from
Jan 5, 2022

Conversation

schlosna
Copy link
Contributor

@schlosna schlosna commented Jan 5, 2022

Before this PR

Subtypes of FilterOutputStream that do not implement write(byte[], int, int) would be inefficient and fall back to single byte writes.

After this PR

==COMMIT_MSG==
If a subclass of FilterOutputStream implements void write(int), they
should also override void write(byte[], int, int), otherwise the
performance of the stream is likely to be slow.

See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FilterOutputStream.html#write(byte%5B%5D,int,int)

Subclasses of FilterOutputStream should provide a more efficient implementation of this method.

Similar in concept to https://errorprone.info/bugpattern/InputStreamSlowMultibyteRead
==COMMIT_MSG==

An example of this being fixed: palantir/hadoop-crypto#42

Possible downsides?

If a subclass of FilterOutputStream implements `void write(int)`, they
should also override `void write(byte[], int, int)`, otherwise the
performance of the stream is likely to be slow.

See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FilterOutputStream.html#write(byte%5B%5D,int,int)
> Subclasses of FilterOutputStream should provide a more efficient implementation of this method.

Similar in concept to https://errorprone.info/bugpattern/InputStreamSlowMultibyteRead
@changelog-app
Copy link

changelog-app bot commented Jan 5, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

If a subclass of FilterOutputStream implements void write(int), they
should also override void write(byte[], int, int), otherwise the
performance of the stream is likely to be slow.

See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FilterOutputStream.html#write(byte%5B%5D,int,int)

Subclasses of FilterOutputStream should provide a more efficient implementation of this method.

Similar in concept to https://errorprone.info/bugpattern/InputStreamSlowMultibyteRead

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from robert3005 January 5, 2022 07:17
Copy link
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

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

Otherwise lgtm, thanks! Feel free to re-add merge-when-ready after fixing the BaselineErrorProneExtension.

…ensions/BaselineErrorProneExtension.java

Co-authored-by: Carter Kozak <ckozak@ckozak.net>
@bulldozer-bot bulldozer-bot bot merged commit cc84035 into develop Jan 5, 2022
@bulldozer-bot bulldozer-bot bot deleted the ds/FilterOutputStreamSlowMultibyteWrite branch January 5, 2022 15:19
@svc-autorelease
Copy link
Collaborator

Released 4.54.0

bulldozer-bot bot pushed a commit to palantir/witchcraft-api that referenced this pull request Jan 5, 2022
###### _excavator_ is a bot for automating changes across repositories.

Changes produced by the roomba/latest-baseline-oss check.

# Release Notes
## 4.54.0
| Type | Description | Link |
| ---- | ----------- | ---- |
| Improvement | If a subclass of FilterOutputStream implements `void write(int)`, they<br>should also override `void write(byte[], int, int)`, otherwise the<br>performance of the stream is likely to be slow.<br><br>See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FilterOutputStream.html#write(byte%5B%5D,int,int)<br>> Subclasses of FilterOutputStream should provide a more efficient implementation of this method.<br><br>Similar in concept to https://errorprone.info/bugpattern/InputStreamSlowMultibyteRead | palantir/gradle-baseline#2024 |



To enable or disable this check, please contact the maintainers of Excavator.
This was referenced Jan 5, 2022
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.

4 participants