You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2007/10/24 04:47:52 UTC

svn commit: r587753 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker: AdjustedSRTServletRequestDump.java ServletPortletInvoker.java

Author: woonsan
Date: Tue Oct 23 19:47:52 2007
New Revision: 587753

URL: http://svn.apache.org/viewvc?rev=587753&view=rev
Log:
[JS2-785] Parallel Rendering on Websphere 6.1

In David's testings, we found this problem:
java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[WORKER_23,5,Workers]
	at java.util.HashMap.onEntry(HashMap.java:205)
	at java.util.HashMap.transfer(HashMap.java:510)
	at java.util.HashMap.resize(HashMap.java:500)
	at java.util.HashMap.addEntry(HashMap.java:800)
	at java.util.HashMap.put(HashMap.java:441)
	at com.ibm.ws.webcontainer.srt.SRTServletRequest.setAttribute(SRTServletRequest.java:466)
	at org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest.setAttribute(AdjustedSRTServletRequest.java)

IMO, because SRTServletRequest#getAttribute() and SRTServletRequest#getAttributeNames() was not synchronized, the internal HashMap, _attributes threw ConcurrentModificationException.

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java?rev=587753&r1=587752&r2=587753&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java Tue Oct 23 19:47:52 2007
@@ -18,14 +18,15 @@
 /*
  * Generated by ASM utility, ASMifierClassVisitor like the following commands:
  *     > java -classpath lib/asm-all-2.2.jar org.objectweb.asm.util.ASMifierClassVisitor \
- *           org.apache.jetspeed.container.AdjustedSRTServletRequest > AdjustedSRTServletRequestDump.java
+ *           org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest > AdjustedSRTServletRequestDump.java
  *     > java -classpath lib/asm-all-2.2.jar org.objectweb.asm.util.ASMifierClassVisitor \
- *           org.apache.jetspeed.container.AdjustedSRTServletRequest$1 > AdjustedSRTServletRequest$1Dump.java
+ *           org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest$1 > AdjustedSRTServletRequest$1Dump.java
  *
  * And, the latter was merged into the former, replacing the method name, 'dump' to 'dumpInner1'.
  */
 
 /*
+// Source for AdjustedSRTServletRequest class to generate AdjustedSRTServletRequestDump.java
 package org.apache.jetspeed.container.invoker;
 
 import com.ibm.ws.webcontainer.core.Response;
@@ -103,12 +104,18 @@
     
     public Object getPrivateAttribute(String s)
     {
-        return this.srtServletRequest.getPrivateAttribute(s);
+        synchronized (this.srtServletRequest)
+        {
+            return this.srtServletRequest.getPrivateAttribute(s);
+        }
     }
     
     public Enumeration getPrivateAttributeNames()
     {
-        return this.srtServletRequest.getPrivateAttributeNames();
+        synchronized (this.srtServletRequest)
+        {
+            return this.srtServletRequest.getPrivateAttributeNames();
+        }
     }
     
     public void setPrivateAttribute(String s, Object obj)
@@ -130,7 +137,10 @@
         
         if (value == null)
         {
-            value = this.srtServletRequest.getAttribute(s);
+            synchronized (this.srtServletRequest)
+            {
+                value = this.srtServletRequest.getAttribute(s);
+            }
         }
         
         return value;
@@ -138,7 +148,10 @@
     
     public Enumeration getAttributeNames()
     {
-        return this.srtServletRequest.getAttributeNames();
+        synchronized (this.srtServletRequest)
+        {
+            return this.srtServletRequest.getAttributeNames();
+        }
     }
     
     public void setCharacterEncoding(String s)
@@ -643,7 +656,7 @@
         }
         
         {
-            fv = cw.visitField(ACC_STATIC + ACC_SYNTHETIC, "class$org$apache$jetspeed$container$AdjustedSRTServletRequest", "Ljava/lang/Class;", null, null);
+            fv = cw.visitField(ACC_STATIC + ACC_SYNTHETIC, "class$org$apache$jetspeed$container$invoker$AdjustedSRTServletRequest", "Ljava/lang/Class;", null, null);
             fv.visitEnd();
         }
         
@@ -738,23 +751,67 @@
         {
             mv = cw.visitMethod(ACC_PUBLIC, "getPrivateAttribute", "(Ljava/lang/String;)Ljava/lang/Object;", null, null);
             mv.visitCode();
+            Label l0 = new Label();
+            Label l1 = new Label();
+            Label l2 = new Label();
+            mv.visitTryCatchBlock(l0, l1, l2, null);
+            Label l3 = new Label();
+            mv.visitTryCatchBlock(l2, l3, l2, null);
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
+            mv.visitInsn(DUP);
+            mv.visitVarInsn(ASTORE, 2);
+            mv.visitInsn(MONITORENTER);
+            mv.visitLabel(l0);
             mv.visitVarInsn(ALOAD, 0);
             mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
             mv.visitVarInsn(ALOAD, 1);
             mv.visitMethodInsn(INVOKEVIRTUAL, "com/ibm/ws/webcontainer/srt/SRTServletRequest", "getPrivateAttribute", "(Ljava/lang/String;)Ljava/lang/Object;");
+            mv.visitVarInsn(ALOAD, 2);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l1);
             mv.visitInsn(ARETURN);
-            mv.visitMaxs(2, 2);
+            mv.visitLabel(l2);
+            mv.visitVarInsn(ASTORE, 3);
+            mv.visitVarInsn(ALOAD, 2);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l3);
+            mv.visitVarInsn(ALOAD, 3);
+            mv.visitInsn(ATHROW);
+            mv.visitMaxs(2, 4);
             mv.visitEnd();
         }
         
         {
             mv = cw.visitMethod(ACC_PUBLIC, "getPrivateAttributeNames", "()Ljava/util/Enumeration;", null, null);
             mv.visitCode();
+            Label l0 = new Label();
+            Label l1 = new Label();
+            Label l2 = new Label();
+            mv.visitTryCatchBlock(l0, l1, l2, null);
+            Label l3 = new Label();
+            mv.visitTryCatchBlock(l2, l3, l2, null);
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
+            mv.visitInsn(DUP);
+            mv.visitVarInsn(ASTORE, 1);
+            mv.visitInsn(MONITORENTER);
+            mv.visitLabel(l0);
             mv.visitVarInsn(ALOAD, 0);
             mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
             mv.visitMethodInsn(INVOKEVIRTUAL, "com/ibm/ws/webcontainer/srt/SRTServletRequest", "getPrivateAttributeNames", "()Ljava/util/Enumeration;");
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l1);
             mv.visitInsn(ARETURN);
-            mv.visitMaxs(1, 1);
+            mv.visitLabel(l2);
+            mv.visitVarInsn(ASTORE, 2);
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l3);
+            mv.visitVarInsn(ALOAD, 2);
+            mv.visitInsn(ATHROW);
+            mv.visitMaxs(2, 3);
             mv.visitEnd();
         }
         
@@ -811,32 +868,77 @@
         {
             mv = cw.visitMethod(ACC_PUBLIC, "getAttribute", "(Ljava/lang/String;)Ljava/lang/Object;", null, null);
             mv.visitCode();
+            Label l0 = new Label();
+            Label l1 = new Label();
+            Label l2 = new Label();
+            mv.visitTryCatchBlock(l0, l1, l2, null);
+            Label l3 = new Label();
+            mv.visitTryCatchBlock(l2, l3, l2, null);
             mv.visitVarInsn(ALOAD, 1);
             mv.visitMethodInsn(INVOKESTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "getThreadLocalAttribute", "(Ljava/lang/String;)Ljava/lang/Object;");
             mv.visitVarInsn(ASTORE, 2);
             mv.visitVarInsn(ALOAD, 2);
-            Label l0 = new Label();
-            mv.visitJumpInsn(IFNONNULL, l0);
+            Label l4 = new Label();
+            mv.visitJumpInsn(IFNONNULL, l4);
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
+            mv.visitInsn(DUP);
+            mv.visitVarInsn(ASTORE, 3);
+            mv.visitInsn(MONITORENTER);
+            mv.visitLabel(l0);
             mv.visitVarInsn(ALOAD, 0);
             mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
             mv.visitVarInsn(ALOAD, 1);
             mv.visitMethodInsn(INVOKEVIRTUAL, "com/ibm/ws/webcontainer/srt/SRTServletRequest", "getAttribute", "(Ljava/lang/String;)Ljava/lang/Object;");
             mv.visitVarInsn(ASTORE, 2);
-            mv.visitLabel(l0);
+            mv.visitVarInsn(ALOAD, 3);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l1);
+            mv.visitJumpInsn(GOTO, l4);
+            mv.visitLabel(l2);
+            mv.visitVarInsn(ASTORE, 4);
+            mv.visitVarInsn(ALOAD, 3);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l3);
+            mv.visitVarInsn(ALOAD, 4);
+            mv.visitInsn(ATHROW);
+            mv.visitLabel(l4);
             mv.visitVarInsn(ALOAD, 2);
             mv.visitInsn(ARETURN);
-            mv.visitMaxs(2, 3);
+            mv.visitMaxs(2, 5);
             mv.visitEnd();
         }
         
         {
             mv = cw.visitMethod(ACC_PUBLIC, "getAttributeNames", "()Ljava/util/Enumeration;", null, null);
             mv.visitCode();
+            Label l0 = new Label();
+            Label l1 = new Label();
+            Label l2 = new Label();
+            mv.visitTryCatchBlock(l0, l1, l2, null);
+            Label l3 = new Label();
+            mv.visitTryCatchBlock(l2, l3, l2, null);
+            mv.visitVarInsn(ALOAD, 0);
+            mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
+            mv.visitInsn(DUP);
+            mv.visitVarInsn(ASTORE, 1);
+            mv.visitInsn(MONITORENTER);
+            mv.visitLabel(l0);
             mv.visitVarInsn(ALOAD, 0);
             mv.visitFieldInsn(GETFIELD, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "srtServletRequest", "Lcom/ibm/ws/webcontainer/srt/SRTServletRequest;");
             mv.visitMethodInsn(INVOKEVIRTUAL, "com/ibm/ws/webcontainer/srt/SRTServletRequest", "getAttributeNames", "()Ljava/util/Enumeration;");
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l1);
             mv.visitInsn(ARETURN);
-            mv.visitMaxs(1, 1);
+            mv.visitLabel(l2);
+            mv.visitVarInsn(ASTORE, 2);
+            mv.visitVarInsn(ALOAD, 1);
+            mv.visitInsn(MONITOREXIT);
+            mv.visitLabel(l3);
+            mv.visitVarInsn(ALOAD, 2);
+            mv.visitInsn(ATHROW);
+            mv.visitMaxs(2, 3);
             mv.visitEnd();
         }
         
@@ -1940,17 +2042,17 @@
             mv.visitTypeInsn(NEW, "java/lang/StringBuffer");
             mv.visitInsn(DUP);
             mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuffer", "<init>", "()V");
-            mv.visitFieldInsn(GETSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$AdjustedSRTServletRequest", "Ljava/lang/Class;");
+            mv.visitFieldInsn(GETSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$invoker$AdjustedSRTServletRequest", "Ljava/lang/Class;");
             Label l0 = new Label();
             mv.visitJumpInsn(IFNONNULL, l0);
             mv.visitLdcInsn("org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest");
             mv.visitMethodInsn(INVOKESTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$", "(Ljava/lang/String;)Ljava/lang/Class;");
             mv.visitInsn(DUP);
-            mv.visitFieldInsn(PUTSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$AdjustedSRTServletRequest", "Ljava/lang/Class;");
+            mv.visitFieldInsn(PUTSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$invoker$AdjustedSRTServletRequest", "Ljava/lang/Class;");
             Label l1 = new Label();
             mv.visitJumpInsn(GOTO, l1);
             mv.visitLabel(l0);
-            mv.visitFieldInsn(GETSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$AdjustedSRTServletRequest", "Ljava/lang/Class;");
+            mv.visitFieldInsn(GETSTATIC, "org/apache/jetspeed/container/invoker/AdjustedSRTServletRequest", "class$org$apache$jetspeed$container$invoker$AdjustedSRTServletRequest", "Ljava/lang/Class;");
             mv.visitLabel(l1);
             mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getName", "()Ljava/lang/String;");
             mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuffer", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;");

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java?rev=587753&r1=587752&r2=587753&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java Tue Oct 23 19:47:52 2007
@@ -375,8 +375,28 @@
         public Class defineAdjustedSRTServletRequestClass() throws Throwable
         {
             byte [] bytes = AdjustedSRTServletRequestDump.dumpInner1();
+            
+            //if (log.isDebugEnabled())
+            //{
+            //    java.io.File classFile = java.io.File.createTempFile("AdjustedSRTServletRequest$1.class.", ".tmp");
+            //    java.io.FileOutputStream fos = new java.io.FileOutputStream(classFile);
+            //    fos.write(bytes, 0, bytes.length);
+            //    fos.close();
+            //    log.debug("Generated a class. See " + classFile.getCanonicalPath());
+            //}
+            
             Class inner1 = defineClass("org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest$1", bytes, 0, bytes.length);
             bytes = AdjustedSRTServletRequestDump.dump();
+            
+            //if (log.isDebugEnabled())
+            //{
+            //    java.io.File classFile = java.io.File.createTempFile("AdjustedSRTServletRequest.class.", ".tmp");
+            //    java.io.FileOutputStream fos = new java.io.FileOutputStream(classFile);
+            //    fos.write(bytes, 0, bytes.length);
+            //    fos.close();
+            //    log.debug("Generated a class. See " + classFile.getCanonicalPath());
+            //}
+            
             return defineClass("org.apache.jetspeed.container.invoker.AdjustedSRTServletRequest", bytes, 0, bytes.length);
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org