Skip to content

Commit

Permalink
Fix BatchCompilerTest - ZipFile "used by another process" on win ecli…
Browse files Browse the repository at this point in the history
…pse-jdt#2766

eclipse-jdt#2766

Works around error in JDK which forgets to close Jar when
System.getSecurityManager()==null

As workaround trigger a GC to make a associated Cleaner Run for the
ZipFile no longer referenced.
  • Loading branch information
EcljpseB0T committed Aug 14, 2024
1 parent f890abb commit 8ee066e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1305,13 +1305,18 @@ private static boolean waitUntilFileDeleted(File file) {
printFileInfo(file.getParentFile(), 1, -1); // display parent with its children
System.out.print(" - wait for ("+DELETE_MAX_WAIT+"ms max): ");
}
int count = 0;
int delay = 10; // ms
int count = -1;
int delay = 1; // ms
int maxRetry = DELETE_MAX_WAIT / delay;
int time = 0;
while (count < maxRetry) {
try {
count++;

// manually trigger GC to invoke Cleaner for ZipFile that is forgotten to be closed
// see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2766
System.gc(); // workaround

Thread.sleep(delay);
time += delay;
if (time > DELETE_MAX_TIME) DELETE_MAX_TIME = time;
Expand Down

0 comments on commit 8ee066e

Please sign in to comment.