Add explicit writeUTF/readUTF javadoc to LittleEndian stream classes#8299
Open
daguimu wants to merge 1 commit intogoogle:masterfrom
Open
Add explicit writeUTF/readUTF javadoc to LittleEndian stream classes#8299daguimu wants to merge 1 commit intogoogle:masterfrom
daguimu wants to merge 1 commit intogoogle:masterfrom
Conversation
The inherited javadoc from DataOutput/DataInput references writeShort and readUnsignedShort for the UTF length prefix, which in these classes use little-endian byte order. However, writeUTF/readUTF actually delegate to standard DataOutputStream/DataInputStream, which use big-endian for the length prefix. This is misleading. Added explicit javadoc to clarify that the 2-byte UTF length prefix uses big-endian byte order, unlike the other methods in these classes. Fixes google#1659
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LittleEndianDataOutputStream.writeUTF()andLittleEndianDataInputStream.readUTF()inherit their javadoc fromDataOutputandDataInput. The inherited documentation referenceswriteShortandreadUnsignedShortfor the UTF string length prefix encoding, which in these classes use little-endian byte order. However, the actual implementations delegate to standardDataOutputStream.writeUTF()andDataInputStream.readUTF(), which encode the length prefix in big-endian byte order.Root Cause
These methods had no explicit javadoc, so they inherited documentation that became misleading in the context of little-endian stream classes.
Fix
writeUTF()inLittleEndianDataOutputStreamclarifying the big-endian length prefixreadUTF()inLittleEndianDataInputStreamclarifying the big-endian length prefixImpact
Javadoc-only change. No behavioral change. Prevents users from incorrectly assuming the UTF length prefix is little-endian.
Fixes #1659