Skip to content

Commit 6ffd006

Browse files
committed
8241806: The sun/awt/shell/FileSystemViewMemoryLeak.java is unstable
Backport-of: e730e8b
1 parent f5a04fb commit 6ffd006

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
@@ -216,7 +216,6 @@ java/awt/image/MultiResolutionImage/MultiResolutionDrawImageWithTransformTest.ja
216216
java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all
217217
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
218218
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
219-
sun/awt/shell/FileSystemViewMemoryLeak.java 8241806 windows-all
220219
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
221220
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all
222221
sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java 8144029 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)