changeset 156:9a504cfa4f64

Fix race condition.
author Denis Lila <dlila@redhat.com>
date Tue, 08 Mar 2011 09:43:59 -0500
parents 07924a054c63
children 6dd840d6a04d
files ChangeLog plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 07 17:09:22 2011 -0500
+++ b/ChangeLog	Tue Mar 08 09:43:59 2011 -0500
@@ -1,3 +1,10 @@
+2011-03-08  Denis Lila  <dlila@redhat.com>
+
+	* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+	(getRequestIdentifier): Fix race condition by synchronizing
+	on mutex.
+	(requestIdentityCounter): Now a long.
+
 2011-03-07  Omair Majid  <omajid@redhat.com>
 
 	* acinclude.m4 (IT_FIND_RHINO_JAR): Set RHINO_AVAILABLE to true or false
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Mon Mar 07 17:09:22 2011 -0500
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Tue Mar 08 09:43:59 2011 -0500
@@ -356,7 +356,8 @@
 
     public static final int APPLET_TIMEOUT = 180000;
 
-    private static Long requestIdentityCounter = 0L;
+    private static final Object requestMutex = new Object();
+    private static long requestIdentityCounter = 0L;
 
     private Image bufFrameImg;
     private Graphics bufFrameImgGraphics;
@@ -990,11 +991,11 @@
      *
      *  @return A unique Long identifier for the request
      */
-    private static Long getRequestIdentifier() {
-        synchronized (requestIdentityCounter) {
-
-            if (requestIdentityCounter == Long.MAX_VALUE)
+    private static long getRequestIdentifier() {
+        synchronized(requestMutex) {
+            if (requestIdentityCounter == Long.MAX_VALUE) {
                 requestIdentityCounter = 0L;
+            }
 
             return requestIdentityCounter++;
         }