RFR: 8259956: jdk.jfr.internal.ChunkInputStream#available should return the sum of remaining available bytes [v6]

Denghui Dong ddong at openjdk.java.net
Wed Feb 3 13:52:09 UTC 2021


On Wed, 3 Feb 2021 11:47:43 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

>> 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);
>                     }
>                 }
>             }
>         }
>      }

Make sense.
Updated.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2138


More information about the hotspot-jfr-dev mailing list