Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8335231: [macos] Test java/awt/print/PrinterJob/Cancel/PrinterJobCancel.java failed on macOS because the case didn't get the expected PrintAbortException #20027

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
Copy link
Contributor

Choose a reason for hiding this comment

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

Update copyright year

Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ public SecondaryLoop run() {

try {
printLoop(true, firstPage, lastPage);
} catch (PrinterAbortException pex) {
throw new PrinterAbortException(pex.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -743,23 +745,15 @@ private void setSides(int sides) {
}
}

private boolean cancelCheck() {
private boolean cancelCheck() throws PrinterAbortException {
// This is called from the native side.

// This is used to avoid deadlock
// We would like to just call if isCancelled(),
// but that will block the AppKit thread against whomever is holding the synchronized lock
boolean cancelled = (performingPrinting && userCancelled);
if (cancelled) {
try {
LWCToolkit.invokeLater(new Runnable() { public void run() {
try {
cancelDoc();
} catch (PrinterAbortException pae) {
// no-op, let the native side handle it
}
}}, null);
} catch (java.lang.reflect.InvocationTargetException ite) {}
cancelDoc();
}
return cancelled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/*
* @test
* @bug 4245280
* @bug 4245280 8335231
* @key printer
* @summary PrinterJob not cancelled when PrinterJob.cancel() is used
* @library /java/awt/regtesthelpers
Expand Down