United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6653384 Variable "initialized" in class CUPSPrinter is static by mistake
JDK-6653384 : Variable "initialized" in class CUPSPrinter is static by mistake

Details
Type:
Bug
Submit Date:
2008-01-22
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-01-09
Component:
client-libs
OS:
linux
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Suse Linus Enterprice Server 10

output of uname -a:
Linux <hostname> 2.6.16.21-0.8-bigsmp #1 SMP Mon Jul 3 18:25:39 UTC 2006 i686 i686 i386 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
CUPS version 1.1.23

A DESCRIPTION OF THE PROBLEM :
Today I found yet another bug in the sun.print.CUPSPrinter class, which as well is responsible for the following NullPointerException (especially in a multi threaded application, see as well Bug ID 6390756):

    java.lang.NullPointerException
            at sun.print.IPPPrintService.findCustomMedia(IPPPrintService.java:845)
            at sun.print.UnixPrintJob.print(UnixPrintJob.java:328)
            ...

In the source of class sun.print.CUPSPrinter, I saw that the variable "initialized" was on the one hand a static variable and on the other hand used to control the initialization of instance variables (im particular the array cupsCustomMediaSNames) in method initMedia(). This of cource causes trouble when more than one CUPSPrinter instances are created, without calling initMedia() immediately after instantiation (to be precise: before the next CUPSPrinter instance is created).



REPRODUCIBILITY :
This bug can be reproduced often.

                                    

Comments
EVALUATION

As described, need to remove static and synchronize initMedia.
                                     
2008-11-11



Hardware and Software, Engineered to Work Together