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 89ceaa9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1306,12 +1306,17 @@ private static boolean waitUntilFileDeleted(File file) {
System.out.print(" - wait for ("+DELETE_MAX_WAIT+"ms max): ");
}
int count = 0;
int delay = 10; // ms
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 89ceaa9

Please sign in to comment.