@@ -49,7 +49,7 @@ public final class SplashWindow extends Window implements MouseListener {
4949 /**
5050 * The current instance of the splash window. (Singleton design pattern).
5151 */
52- private static volatile SplashWindow instance = null ;
52+ private static /* volatile*/ SplashWindow instance = null ;
5353
5454 /**
5555 * The splash image which is displayed on the splash window.
@@ -84,7 +84,7 @@ private SplashWindow(Frame parent, Image image) {
8484 mt .addImage (image , 0 );
8585 try {
8686 mt .waitForID (0 );
87- } catch (InterruptedException ie ) {
87+ } catch (InterruptedException ie ) { //NOSONAR java:S2142
8888 log .warn (ie .toString ());
8989 }
9090
@@ -123,20 +123,25 @@ public void mouseClicked(MouseEvent e) {
123123 }
124124
125125 public void mousePressed (MouseEvent e ) {
126+ // Handle mouse click event only
126127 }
127128
128129 public void mouseReleased (MouseEvent e ) {
130+ // Handle mouse click event only
129131 }
130132
131133 public void mouseEntered (MouseEvent e ) {
134+ // Handle mouse click event only
132135 }
133136
134137 public void mouseExited (MouseEvent e ) {
138+ // Handle mouse click event only
135139 }
136140
137141 /**
138142 * Updates the display area of the window.
139143 */
144+ @ Override
140145 public void update (Graphics g ) {
141146 // [*] Since the paint method is going to draw an
142147 // image that covers the complete area of the component we
@@ -147,6 +152,7 @@ public void update(Graphics g) {
147152 /**
148153 * Paints the image on the window.
149154 */
155+ @ Override
150156 public void paint (Graphics g ) {
151157 if (null == g ) {
152158 throw new NullArgumentException ("g" );
@@ -168,14 +174,19 @@ public void paint(Graphics g) {
168174 *
169175 * @param image The splash image.
170176 */
171- @ SuppressWarnings ("SynchronizeOnNonFinalField" )
172177 public static void splash (Image image ) {
173178 if (instance != null || image == null ) {
174179 return ;
175180 }
176181
177182 // Create the splash image
178- instance = new SplashWindow (new Frame (), image );
183+ SplashWindow splasher = new SplashWindow (new Frame (), image );
184+ synchronized (log ) {
185+ if (instance != null ) {
186+ return ;
187+ }
188+ instance = splasher ;
189+ }
179190
180191 // Show the window.
181192 instance .setVisible (true );
@@ -186,11 +197,11 @@ public static void splash(Image image) {
186197 // If more than one processor is available, we don't wait,
187198 // and maximize CPU throughput instead.
188199 if (!EventQueue .isDispatchThread () && Runtime .getRuntime ().availableProcessors () == 1 ) {
189- synchronized (instance ) {
200+ synchronized (log ) {
190201 while (!instance .isPaintCalled ) {
191202 try {
192203 instance .wait ();
193- } catch (InterruptedException e ) {
204+ } catch (InterruptedException e ) { //NOSONAR java:S2142
194205 log .warn (e .toString ());
195206 }
196207 }
0 commit comments