-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b73
-
x86
-
linux
The following program throws NPE in CUPS because the default media is null.
Media is a common attribute and should not be returning null. If CUPS printer is misconfigured that it returns null, jdk should be able to recover and return an acceptable default value like letter or a4 depending on locale.
-------------------------------------------
public static void main(String theParams[])
{
PrintService thePS = PrintServiceLookup.lookupDefaultPrintService();
MediaPrintableArea thePrintableArea = null;
MediaSize theMediaSize = null;
Media theMedia = null;
String theMarginsString = null;
float theTopMargin = 0;
float theLeftMargin = 0;
float theBottomMargin = 0;
float theRightMargin = 0;
int theUnits = MediaPrintableArea.INCH;
thePrintableArea = (MediaPrintableArea)thePS.getDefaultAttributeValue(MediaPrintableArea.class);
theMedia = (Media)thePS.getDefaultAttributeValue(Media.class);
theMediaSize = MediaSize.getMediaSizeForName((MediaSizeName)theMedia);
System.out.println("Print Service: " + thePS);
System.out.println("Default Media: " + theMedia.getClass() + " [" + theMedia);
System.out.println(" Default Size: " + theMediaSize.getClass() + " [" + theMediaSize.toString(theUnits, "in"));
System.out.println(" Print Area: " + thePrintableArea.toString(theUnits, "in"));
}
Tested using seahund linux machine.
Media is a common attribute and should not be returning null. If CUPS printer is misconfigured that it returns null, jdk should be able to recover and return an acceptable default value like letter or a4 depending on locale.
-------------------------------------------
public static void main(String theParams[])
{
PrintService thePS = PrintServiceLookup.lookupDefaultPrintService();
MediaPrintableArea thePrintableArea = null;
MediaSize theMediaSize = null;
Media theMedia = null;
String theMarginsString = null;
float theTopMargin = 0;
float theLeftMargin = 0;
float theBottomMargin = 0;
float theRightMargin = 0;
int theUnits = MediaPrintableArea.INCH;
thePrintableArea = (MediaPrintableArea)thePS.getDefaultAttributeValue(MediaPrintableArea.class);
theMedia = (Media)thePS.getDefaultAttributeValue(Media.class);
theMediaSize = MediaSize.getMediaSizeForName((MediaSizeName)theMedia);
System.out.println("Print Service: " + thePS);
System.out.println("Default Media: " + theMedia.getClass() + " [" + theMedia);
System.out.println(" Default Size: " + theMediaSize.getClass() + " [" + theMediaSize.toString(theUnits, "in"));
System.out.println(" Print Area: " + thePrintableArea.toString(theUnits, "in"));
}
Tested using seahund linux machine.
- relates to
-
JDK-6387255 PIT: isAttrValueSupported and getSupportedAttrValues are in conflict for Media Attribute, on Linux
- Resolved