Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit a67f890

Browse files
kvergizovaAndrew Brygin
authored and
Andrew Brygin
committedSep 17, 2020
8253050: jfr disassemble command processes --max-chunks incorrectly
Reviewed-by: egahlin
1 parent f972155 commit a67f890

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed
 

‎src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Disassemble.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,13 @@ private List<Long> combineChunkSizes(List<Long> sizes, int maxChunks, long maxSi
182182
long fileSize = sizes.get(0);
183183
for (int i = 1; i < sizes.size(); i++) {
184184
long size = sizes.get(i);
185-
if (fileSize + size > maxSize) {
185+
if (fileSize + size > maxSize || chunks == maxChunks) {
186186
reduced.add(fileSize);
187187
chunks = 1;
188188
fileSize = size;
189189
continue;
190190
}
191191
fileSize += size;
192-
if (chunks == maxChunks) {
193-
reduced.add(fileSize);
194-
fileSize = 0;
195-
chunks = 1;
196-
continue;
197-
}
198192
chunks++;
199193
}
200194
if (fileSize != 0) {

‎test/jdk/jdk/jfr/tool/TestDisassemble.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
4040

4141
/**
4242
* @test
43+
* @bug 8253050
4344
* @summary Test jfr split
4445
* @key jfr
4546
* @requires vm.hasJFR
@@ -55,13 +56,16 @@ public static void main(String[] args) throws Throwable {
5556
Path recordingFileA = Paths.get("many-chunks-A-" + dateText + ".jfr");
5657
Path recordingFileB = Paths.get("many-chunks-B-" + dateText + ".jfr");
5758
Path recordingFileC = Paths.get("many-chunks-C-" + dateText + ".jfr");
59+
Path recordingFileD = Paths.get("many-chunks-D-" + dateText + ".jfr");
5860
makeRecordingWithChunks(6, recordingFileA);
5961
Files.copy(recordingFileA, recordingFileB);
6062
Files.copy(recordingFileA, recordingFileC);
63+
Files.copy(recordingFileA, recordingFileD);
6164

6265
String fileAText = recordingFileA.toAbsolutePath().toString();
6366
String fileBText = recordingFileB.toAbsolutePath().toString();
6467
String fileCText = recordingFileC.toAbsolutePath().toString();
68+
String fileDText = recordingFileD.toAbsolutePath().toString();
6569

6670
OutputAnalyzer output = ExecuteHelper.jfr("disassemble");
6771
output.shouldContain("missing file");
@@ -97,6 +101,15 @@ public static void main(String[] args) throws Throwable {
97101
// sanity check
98102
output = ExecuteHelper.jfr("disassemble", "--max-size", "10000", fileCText);
99103
verifyRecording(fileCText.substring(0, fileCText.length() - 4) + "_01.jfr");
104+
105+
// test JDK-8253050
106+
output = ExecuteHelper.jfr("disassemble", "--max-chunks", "1", fileDText);
107+
String chunks = output.firstMatch("File consists of (\\d+) chunks", 1);
108+
output.shouldContain("The recording will be split into " + chunks + " files");
109+
String chunkFilePrefix = fileDText.substring(0, fileDText.length() - 4) + "_";
110+
for (long i = 0; i < Long.parseLong(chunks); i++) {
111+
verifyRecording(chunkFilePrefix + String.format("%0" + chunks.length() + "d", i) + ".jfr");
112+
}
100113
}
101114

102115
private static void verifyRecording(String name) throws IOException {

0 commit comments

Comments
 (0)
This repository has been archived.