[OpenJDK 2D-Dev] [9] RFR: Test closed/javax/print/attribute/Services_getDocFl.java fails with NullpointerException

prasanta sadhukhan prasanta.sadhukhan at oracle.com
Wed Dec 2 10:35:34 UTC 2015


Hi All,

Please review a fix for jdk9
Bug: https://bugs.openjdk.java.net/browse/JDK-8040139
webrev: http://cr.openjdk.java.net/~jdv/prasanta/8040139/webrev.00/

It seems if a IPP printer is not accessible, 
PrintServiceLookup.lookupPrintServices will return the printer service 
but PrintService.getSupportedDocFlavors() will return null
since for the printer there is no way to answer the questions as to what 
it supports and if after that someone tries to access flavors.length it 
will cause NPE.
However, as per spec
/https://docs.oracle.com/javase/8/docs/api/index.html?javax/print/PrintService.html//
//it clearly says, //
/

/Returns:/
    /Array of supported doc flavors, should have at least one element./


so returning null is a violation of spec.
I have added a fix to return DocService.SERVICE_FORMATTED flavor for 
such case.

Could not add a reg testcase as it will need an inaccessible printer.

Regards
Prasanta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20151202/b357ca12/attachment.html>


More information about the 2d-dev mailing list