Skip to content

Commit 410aa33

Browse files
jisedlacthurka
authored andcommitted
GH-111 Delete also the .hwcache directory when deleting a heap dump
1 parent 6010c00 commit 410aa33

File tree

1 file changed

+17
-0
lines changed
  • visualvm/heapdump/src/com/sun/tools/visualvm/heapdump

1 file changed

+17
-0
lines changed

visualvm/heapdump/src/com/sun/tools/visualvm/heapdump/HeapDump.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.sun.tools.visualvm.core.snapshot.Snapshot;
3030
import com.sun.tools.visualvm.core.snapshot.SnapshotsSupport;
3131
import java.io.File;
32+
import org.graalvm.visualvm.core.datasupport.Utils;
3233
import org.openide.util.NbBundle;
3334

3435
/**
@@ -39,6 +40,8 @@
3940
*/
4041
public abstract class HeapDump extends Snapshot {
4142

43+
private static final String HWCACHE_EXT = ".hwcache"; // NOI18N
44+
4245
/**
4346
* Creates new instance of HeapDump with the data stored in a file.
4447
*
@@ -65,5 +68,19 @@ public boolean supportsSaveAs() {
6568
public void saveAs() {
6669
SnapshotsSupport.getInstance().saveAs(this, NbBundle.getMessage(HeapDump.class, "LBL_Save_Heap_Dump_As")); // NOI18N
6770
}
71+
72+
protected void remove() {
73+
final File f = getFile();
74+
75+
// #GH-111: delete the corresponding .hwcache directory
76+
if (f != null) Utils.FILE_QUEUE.post(new Runnable() {
77+
public void run() {
78+
File ff = new File(f.getParent(), f.getName() + HWCACHE_EXT);
79+
if (ff.isDirectory()) Utils.delete(ff, true);
80+
}
81+
});
82+
83+
super.remove();
84+
}
6885

6986
}

0 commit comments

Comments
 (0)