Skip to content

Commit

Permalink
8292305: [BACKOUT] JDK-8289208 Test DrawRotatedStringUsingRotatedFont…
Browse files Browse the repository at this point in the history
….java occasionally crashes on MacOS

Reviewed-by: prr, dholmes
  • Loading branch information
Daniel D. Daugherty committed Aug 12, 2022
1 parent 22d6d31 commit e70747b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 136 deletions.
39 changes: 20 additions & 19 deletions src/java.desktop/share/classes/sun/java2d/Disposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.concurrent.ConcurrentLinkedDeque;

/**
* This class is used for registering and disposing the native
Expand Down Expand Up @@ -145,12 +145,12 @@ public void run() {
Reference<?> obj = queue.remove();
obj.clear();
DisposerRecord rec = records.remove(obj);
safeDispose(rec);
rec.dispose();
obj = null;
rec = null;
clearDeferredRecords();
} catch (Exception e) {
e.printStackTrace(System.err);
System.out.println("Exception while removing reference.");
}
}
}
Expand All @@ -164,23 +164,21 @@ public void run() {
public static interface PollDisposable {
};

private static ConcurrentLinkedDeque<DisposerRecord> deferredRecords = new ConcurrentLinkedDeque<>();

private static void safeDispose(DisposerRecord rec) {
try {
rec.dispose();
} catch (final Exception e) {
e.printStackTrace(System.err);
}
}
private static ArrayList<DisposerRecord> deferredRecords = null;

private static void clearDeferredRecords() {
while (!deferredRecords.isEmpty()) {
final DisposerRecord rec = deferredRecords.pollFirst();
if (rec != null) {
safeDispose(rec);
if (deferredRecords == null || deferredRecords.isEmpty()) {
return;
}
for (int i=0;i<deferredRecords.size(); i++) {
try {
DisposerRecord rec = deferredRecords.get(i);
rec.dispose();
} catch (Exception e) {
System.out.println("Exception while disposing deferred rec.");
}
}
deferredRecords.clear();
}

/*
Expand Down Expand Up @@ -213,19 +211,22 @@ public static void pollRemove() {
obj.clear();
DisposerRecord rec = records.remove(obj);
if (rec instanceof PollDisposable) {
safeDispose(rec);
rec.dispose();
obj = null;
rec = null;
} else {
if (rec == null) { // shouldn't happen, but just in case.
continue;
}
deferred++;
deferredRecords.offerLast(rec);
if (deferredRecords == null) {
deferredRecords = new ArrayList<DisposerRecord>(5);
}
deferredRecords.add(rec);
}
}
} catch (Exception e) {
e.printStackTrace(System.err);
System.out.println("Exception while removing reference.");
} finally {
pollingQueue = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

/**
* @test
* @bug 8065373 8289208
* @key headful
* @bug 8065373
* @summary Verifies that we get correct direction, when draw rotated string.
* @author Sergey Bylokhov
* @run main DrawRotatedStringUsingRotatedFont
Expand Down
115 changes: 0 additions & 115 deletions test/jdk/sun/java2d/Disposer/TestDisposerRace.java

This file was deleted.

1 comment on commit e70747b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.