RFR: 8259956: jdk.jfr.internal.ChunkInputStream#available should return the sum of remaining available bytes [v6]
Erik Gahlin
egahlin at openjdk.java.net
Wed Feb 3 11:57:44 UTC 2021
On Tue, 2 Feb 2021 03:22:19 GMT, Denghui Dong <ddong at openjdk.org> wrote:
>> Could I have a review of this small fix?
>>
>> In the current implementation, ChunkInputStream#available only returns the available size of the current stream, which is strange for the user.
>
> Denghui Dong has updated the pull request incrementally with one additional commit since the last revision:
>
> Clean up
test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java line 51:
> 49: .withPeriod(Duration.ofMillis(100));
> 50: r.start();
> 51: File repository = Path.of(System.getProperty("jdk.jfr.repository")).toFile();
I would prefer a simpler and more deterministic test that executes quickly and doesn't involve timing or other events (to reduce false positives).
How about this? (haven't tried it).
public static void main(String... args) throws Exception {
try (Recording r = new Recording()) {
r.start();
try (Recording s = new Recording()) {
s.start(); // rotate
s.stop(); // rotate
}
r.stop();
try (InputStream is = r.getStream(null, null)) {
int left = is.available();
if (left != r.getSize()) {
String msg = "Expected IS::available() " + left;
msg += " to equal recording size " + r.getSize();
throw new Exception(msg);
}
while (is.read() != -1) {
left--;
int available = is.available();
if (available != left) {
String msg = "Expected IS::available() to return " + left;
msg += ", got " + available;
throw new Exception(msg);
}
}
}
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/2138
More information about the hotspot-jfr-dev
mailing list