On Mon, 11 Oct 2021 10:25:01 GMT, Lin Zang <lz...@openjdk.org> wrote:

> The root cause for the fail is that there must be a flush for 
> `BufferedOutputStream` before getting the `pos` of the file, otherwise the 
> data length is wrongly calculated.

Fix seems good. Suggestion on the comment.

Thanks,
David

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
 line 619:

> 617:             out.writeInt(0);
> 618:             // remember position of dump length, we will fixup
> 619:             // length later - hprof format require length.

The comment is not very clear to me. I suggest per your description, to simply 
say:
// We must flush all data to the file before reading the current file position.

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

Marked as reviewed by dholmes (Reviewer).

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

Reply via email to