mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8259956: jdk.jfr.internal.ChunkInputStream#available should return the sum of remaining available bytes
Reviewed-by: egahlin
This commit is contained in:
parent
06b33a0ad7
commit
e8ad8b3504
2 changed files with 64 additions and 3 deletions
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Alibaba Group Holding Limited. 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Alibaba designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test TestChunkInputStreamAvailable
|
||||
* @key jfr
|
||||
* @requires vm.hasJFR
|
||||
* @library /test/lib
|
||||
* @run main/othervm jdk.jfr.api.consumer.TestChunkInputStreamAvailable
|
||||
*/
|
||||
package jdk.jfr.api.consumer;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import jdk.jfr.Recording;
|
||||
import jdk.test.lib.Asserts;
|
||||
|
||||
public class TestChunkInputStreamAvailable {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (Recording r = new Recording()) {
|
||||
r.start();
|
||||
try (Recording s = new Recording()) {
|
||||
s.start();
|
||||
s.stop();
|
||||
}
|
||||
r.stop();
|
||||
try (InputStream stream = r.getStream(null, null)) {
|
||||
int left = stream.available();
|
||||
Asserts.assertEquals(r.getSize(), (long) left);
|
||||
while (stream.read() != -1) {
|
||||
left--;
|
||||
Asserts.assertEquals(left, stream.available());
|
||||
}
|
||||
Asserts.assertEquals(0, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue