Skip to content

Commit e730e8b

Browse files
committed
8241806: The sun/awt/shell/FileSystemViewMemoryLeak.java is unstable
Reviewed-by: jdv, aivanov
1 parent 57b98fa commit e730e8b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all
260260
java/awt/print/PrinterJob/TestPgfmtSetMPA.java 8198343 generic-all
261261
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
262262
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
263-
sun/awt/shell/FileSystemViewMemoryLeak.java 8241806 windows-all
264263
sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java 8022403 generic-all
265264
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
266265
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all,macosx-all

test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 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
@@ -27,10 +27,12 @@
2727
* @summary FileSystemView.isDrive(File) memory leak on "C:\" file reference
2828
* @modules java.desktop/sun.awt.shell
2929
* @requires (os.family == "windows")
30-
* @run main/othervm -Xmx8m FileSystemViewMemoryLeak
30+
* @run main/othervm/timeout=320 -Xmx8m FileSystemViewMemoryLeak
3131
*/
3232
import java.io.File;
3333
import java.text.NumberFormat;
34+
import java.util.concurrent.TimeUnit;
35+
3436
import javax.swing.filechooser.FileSystemView;
3537

3638
public class FileSystemViewMemoryLeak {
@@ -39,6 +41,9 @@ public static void main(String[] args) {
3941
test();
4042
}
4143

44+
// Will run the test no more than 300 seconds
45+
static long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(300);
46+
4247
private static void test() {
4348

4449
File root = new File("C:\\");
@@ -52,6 +57,10 @@ private static void test() {
5257
int iMax = 50000;
5358
long lastPercentFinished = 0L;
5459
for (int i = 0; i < iMax; i++) {
60+
if (isComplete()) {
61+
System.out.println("Time is over");
62+
return;
63+
}
5564

5665
long percentFinished = Math.round(((i * 1000d) / (double) iMax));
5766

@@ -77,5 +86,9 @@ private static void test() {
7786
boolean drive = fileSystemView.isDrive(root);
7887
}
7988
}
89+
90+
private static boolean isComplete() {
91+
return endtime - System.nanoTime() < 0;
92+
}
8093
}
8194

0 commit comments

Comments
 (0)