[OpenJDK 2D-Dev] [9] Review Request: 8046007: Java app receives javax.print.PrintException: Printer is not accepting job

Alexey Ivanov alexey.ivanov at oracle.com
Wed Jul 16 13:09:58 UTC 2014


Please review the fix for jdk9:
     bug: https://bugs.openjdk.java.net/browse/JDK-8046007
     webrev: http://cr.openjdk.java.net/~aivanov/8046007/jdk9/webrev.00/

Problem description:
If printer is an error state for some reason, Java application cannot 
post a new print job to printer queue because of exception:
java.awt.print.PrinterException: Printer is not accepting job.
         at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1326)
         at javax.swing.text.JTextComponent$2.call(JTextComponent.java:2320)
         at java.util.concurrent.FutureTask.run(FutureTask.java:262)
         at javax.swing.text.JTextComponent$3.run(JTextComponent.java:2369)
         at java.lang.Thread.run(Thread.java:744)

At the same time, regular Windows applications (e.g. Word) can still add 
new print jobs to the queue of this printer.

See also related JDK-6996782: RFE: Optionally allow submitting printjobs 
even if Printer is not accepting job
and JDK-6525150: Printer has "paper out" status and won't print due to a 

The fix:
Currently Java checks the status of the printer, and does not allow 
posting a new print job if the printer is in an error state. At the same 
time, the print queue functions without any issues. It is user's 
responsibility to fix a problem with the printer, as soon as it's 
resolved, all the print jobs will be processed by the printer.

Microsoft Knowledge Base article http://support.microsoft.com/kb/160129 
The Printer is assumed ready to accept print jobs … even if the physical 
printer is in an error state such as off-line.

As far as I can see, the only printer state from the list 
that doesn't allow adding new print jobs is 
PRINTER_STATUS_PENDING_DELETION which means "The printer is being 
deleted." Surely one cannot print to a deleted printer.

I tested this fix by disconnecting the network printer. It takes some 
time for printer monitor to update the status before communication error 
is detected. It would not be detected at all until you add at least one 
print job. As soon as the printer driver detects the problem and 
communicates it to Windows, printer queue displays an error state on the 
currently processed print job. From that moment, Java apps cannot print 
to this printer.

With this fix, Java still considers "Accepting jobs" and thus allows 
posting new jobs to the printer queue.

When the connection to the printer is restored, all the queued jobs are 
successfully processed and documents are printed.

Regression test:
I ran regressions tests in jdk/tests/javax/print, and all tests passed.

No regression test is provided due to its complexity. Printer should go 
to an error state, it depends on the printer driver and on whether the 
printer is local or network.

There's a test app and steps to try to reproduce the issue in the JBS 
bug 8046007.

Thank you,

More information about the 2d-dev mailing list