8286386: Address possibly lossy conversions in java.net.http
Reviewed-by: rriggs, michaelm, prappo
This commit is contained in:
parent
7118343737
commit
5ff1d227bb
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,7 +61,7 @@ public class BufferingSubscriber<T> implements TrustedSubscriber<T>
|
||||
/** The internal buffers holding the buffered data. */
|
||||
private ArrayList<ByteBuffer> internalBuffers;
|
||||
/** The actual accumulated remaining bytes in internalBuffers. */
|
||||
private int accumulatedBytes;
|
||||
private long accumulatedBytes;
|
||||
|
||||
/** Holds the Throwable from upstream's onError. */
|
||||
private volatile Throwable throwable;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,8 +63,14 @@ public final class QuickHuffman {
|
||||
return codes[c] & 0xffffffff00000000L;
|
||||
}
|
||||
|
||||
private static long codeLengthOf(char c) {
|
||||
return codes[c] & 0x00000000ffffffffL;
|
||||
private static int codeLengthOf(char c) {
|
||||
// codes are up to 30 bits long - and their length
|
||||
// is coded on 5 bits which means casting to int here is safe: the
|
||||
// returned value is expected to be in the range (5..30) and will
|
||||
// never be negative.
|
||||
int len = (int) (codes[c] & 0x00000000ffffffffL);
|
||||
assert len >= 0;
|
||||
return len;
|
||||
}
|
||||
|
||||
private static final int EOS_LENGTH = 30;
|
||||
@ -732,7 +738,7 @@ public final class QuickHuffman {
|
||||
if (c > 255) {
|
||||
throw new IllegalArgumentException("char=" + ((int) c));
|
||||
}
|
||||
long len = codeLengthOf(c);
|
||||
int len = codeLengthOf(c);
|
||||
if (bufferLen + len <= 64) {
|
||||
buffer |= (codeValueOf(c) >>> bufferLen); // append
|
||||
bufferLen += len;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -215,7 +215,11 @@ final class Frame {
|
||||
if (value) {
|
||||
firstChar |= 0b10000000_00000000;
|
||||
} else {
|
||||
firstChar &= ~0b10000000_00000000;
|
||||
// Explicit cast required:
|
||||
// The negation "~" sets the high order bits
|
||||
// so the value becomes more than 16 bits and the
|
||||
// compiler will emit a warning if not cast
|
||||
firstChar &= (char) ~0b10000000_00000000;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -224,7 +228,8 @@ final class Frame {
|
||||
if (value) {
|
||||
firstChar |= 0b01000000_00000000;
|
||||
} else {
|
||||
firstChar &= ~0b01000000_00000000;
|
||||
// Explicit cast required - see fin() above
|
||||
firstChar &= (char) ~0b01000000_00000000;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -233,7 +238,8 @@ final class Frame {
|
||||
if (value) {
|
||||
firstChar |= 0b00100000_00000000;
|
||||
} else {
|
||||
firstChar &= ~0b00100000_00000000;
|
||||
// Explicit cast required - see fin() above
|
||||
firstChar &= (char) ~0b00100000_00000000;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -242,7 +248,8 @@ final class Frame {
|
||||
if (value) {
|
||||
firstChar |= 0b00010000_00000000;
|
||||
} else {
|
||||
firstChar &= ~0b00010000_00000000;
|
||||
// Explicit cast required - see fin() above
|
||||
firstChar &= (char) ~0b00010000_00000000;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -259,7 +266,7 @@ final class Frame {
|
||||
payloadLen = value;
|
||||
firstChar &= 0b11111111_10000000; // Clear previous payload length leftovers
|
||||
if (payloadLen < 126) {
|
||||
firstChar |= payloadLen;
|
||||
firstChar |= (char) payloadLen;
|
||||
} else if (payloadLen < 65536) {
|
||||
firstChar |= 126;
|
||||
} else {
|
||||
@ -276,7 +283,8 @@ final class Frame {
|
||||
}
|
||||
|
||||
HeaderWriter noMask() {
|
||||
firstChar &= ~0b00000000_10000000;
|
||||
// Explicit cast required: see fin() above
|
||||
firstChar &= (char) ~0b00000000_10000000;
|
||||
mask = false;
|
||||
return this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user