RFR: 8286386: Address possibly lossy conversions in java.net.http [v5]
Michael McMahon
michaelm at openjdk.java.net
Wed May 11 20:34:42 UTC 2022
On Wed, 11 May 2022 17:10:45 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> src/java.net.http/share/classes/jdk/internal/net/http/hpack/QuickHuffman.java line 739:
>>
>>> 737: buffer |= (codeValueOf(c) >>> bufferLen); // append
>>> 738: bufferLen += (int) len;
>>> 739: pos++;
>>
>> Would it be cleaner to do the cast in the codeLengthOf method, so it returns an int?
>
> I believe the method returns an "unsigned int" - having the method return an int would then potentially cause `bufferLen + len <= 64` to yield true when it shouldn't. Hopefully @pavelrappo will comment.
codeLengthOf() returns long. It could be changed to return int with a cast internally and then you could avoid the two new casts.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8656
More information about the net-dev
mailing list