tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1406788 - in /tomcat/trunk: java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/modeler/ java/org/apache/tomcat/util/net/ res/findbugs/ test/org/apache/jasper/tagplugins/jstl/core/
Date Wed, 07 Nov 2012 20:16:19 GMT
Author: markt
Date: Wed Nov  7 20:16:19 2012
New Revision: 1406788

URL: http://svn.apache.org/viewvc?rev=1406788&view=rev
Log:
FindBugs issues

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java
    tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/trunk/res/findbugs/filter-false-positives.xml
    tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/AbstractTestTag.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=1406788&r1=1406787&r2=1406788&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java Wed Nov  7 20:16:19 2012
@@ -1002,6 +1002,13 @@ public class JspUtil {
                 break;
             }
         }
+
+        if (t == null) {
+            // Should never happen
+            throw new IllegalArgumentException("Unable to extract type from [" +
+                    type + "]");
+        }
+
         StringBuilder resultType = new StringBuilder(t);
         for (; dims > 0; dims--) {
             resultType.append("[]");

Modified: tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java?rev=1406788&r1=1406787&r2=1406788&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java Wed Nov  7 20:16:19
2012
@@ -22,6 +22,9 @@ package org.apache.tomcat.util.modeler;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import javax.management.AttributeNotFoundException;
 import javax.management.DynamicMBean;
@@ -55,11 +58,12 @@ public class ManagedBean implements java
     static final Class<?>[] NO_ARGS_PARAM_SIG = new Class[0];
 
 
+    private ReadWriteLock mBeanInfoLock = new ReentrantReadWriteLock();
     /**
      * The <code>ModelMBeanInfo</code> object that corresponds
      * to this <code>ManagedBean</code> instance.
      */
-    transient MBeanInfo info = null;
+    private transient MBeanInfo info = null;
 
     private Map<String,AttributeInfo> attributes = new HashMap<>();
 
@@ -71,7 +75,7 @@ public class ManagedBean implements java
     protected String group = null;
     protected String name = null;
 
-    protected NotificationInfo notifications[] = new NotificationInfo[0];
+    private NotificationInfo notifications[] = new NotificationInfo[0];
     protected String type = null;
 
     /** Constructor. Will add default attributes.
@@ -110,8 +114,14 @@ public class ManagedBean implements java
     }
 
     public void setClassName(String className) {
-        this.className = className;
-        this.info = null;
+        Lock l = mBeanInfoLock.writeLock();
+        l.lock();
+        try {
+            this.className = className;
+            this.info = null;
+        } finally {
+            l.unlock();
+        }
     }
 
 
@@ -123,8 +133,14 @@ public class ManagedBean implements java
     }
 
     public void setDescription(String description) {
-        this.description = description;
-        this.info = null;
+        Lock l = mBeanInfoLock.writeLock();
+        l.lock();
+        try {
+            this.description = description;
+            this.info = null;
+        } finally {
+            l.unlock();
+        }
     }
 
 
@@ -162,8 +178,14 @@ public class ManagedBean implements java
     }
 
     public void setName(String name) {
-        this.name = name;
-        this.info = null;
+        Lock l = mBeanInfoLock.writeLock();
+        l.lock();
+        try {
+            this.name = name;
+            this.info = null;
+        } finally {
+            l.unlock();
+        }
     }
 
 
@@ -195,8 +217,14 @@ public class ManagedBean implements java
     }
 
     public void setType(String type) {
-        this.type = type;
-        this.info = null;
+        Lock l = mBeanInfoLock.writeLock();
+        l.lock();
+        try {
+            this.type = type;
+            this.info = null;
+        } finally {
+            l.unlock();
+        }
     }
 
 
@@ -220,7 +248,10 @@ public class ManagedBean implements java
      */
     public void addNotification(NotificationInfo notification) {
 
-        synchronized (notifications) {
+        Lock l = mBeanInfoLock.writeLock();
+
+        l.lock();
+        try {
             NotificationInfo results[] =
                 new NotificationInfo[notifications.length + 1];
             System.arraycopy(notifications, 0, results, 0,
@@ -228,8 +259,9 @@ public class ManagedBean implements java
             results[notifications.length] = notification;
             notifications = results;
             this.info = null;
+        } finally {
+            l.unlock();
         }
-
     }
 
 
@@ -348,40 +380,51 @@ public class ManagedBean implements java
     MBeanInfo getMBeanInfo() {
 
         // Return our cached information (if any)
-        if (info != null)
-            return (info);
-
-        // Create subordinate information descriptors as required
-        AttributeInfo attrs[] = getAttributes();
-        MBeanAttributeInfo attributes[] =
-            new MBeanAttributeInfo[attrs.length];
-        for (int i = 0; i < attrs.length; i++)
-            attributes[i] = attrs[i].createAttributeInfo();
-
-        OperationInfo opers[] = getOperations();
-        MBeanOperationInfo operations[] =
-            new MBeanOperationInfo[opers.length];
-        for (int i = 0; i < opers.length; i++)
-            operations[i] = opers[i].createOperationInfo();
-
-
-        NotificationInfo notifs[] = getNotifications();
-        MBeanNotificationInfo notifications[] =
-            new MBeanNotificationInfo[notifs.length];
-        for (int i = 0; i < notifs.length; i++)
-            notifications[i] = notifs[i].createNotificationInfo();
-
-
-        // Construct and return a new ModelMBeanInfo object
-        info = new MBeanInfo(getClassName(),
-                             getDescription(),
-                             attributes,
-                             new MBeanConstructorInfo[] {},
-                             operations,
-                             notifications);
-
-        return (info);
+        Lock l = mBeanInfoLock.readLock();
+        l.lock();
+        try {
+            if (info != null)
+                return info;
+        } finally {
+            l.unlock();
+        }
 
+        l = mBeanInfoLock.writeLock();
+        l.lock();
+        try {
+            // Create subordinate information descriptors as required
+            AttributeInfo attrs[] = getAttributes();
+            MBeanAttributeInfo attributes[] =
+                new MBeanAttributeInfo[attrs.length];
+            for (int i = 0; i < attrs.length; i++)
+                attributes[i] = attrs[i].createAttributeInfo();
+
+            OperationInfo opers[] = getOperations();
+            MBeanOperationInfo operations[] =
+                new MBeanOperationInfo[opers.length];
+            for (int i = 0; i < opers.length; i++)
+                operations[i] = opers[i].createOperationInfo();
+
+
+            NotificationInfo notifs[] = getNotifications();
+            MBeanNotificationInfo notifications[] =
+                new MBeanNotificationInfo[notifs.length];
+            for (int i = 0; i < notifs.length; i++)
+                notifications[i] = notifs[i].createNotificationInfo();
+
+
+            // Construct and return a new ModelMBeanInfo object
+            info = new MBeanInfo(getClassName(),
+                                 getDescription(),
+                                 attributes,
+                                 new MBeanConstructorInfo[] {},
+                                 operations,
+                                 notifications);
+
+            return info;
+        } finally {
+            l.unlock();
+        }
     }
 
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1406788&r1=1406787&r2=1406788&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed Nov  7 20:16:19 2012
@@ -1630,7 +1630,9 @@ public class NioEndpoint extends Abstrac
                     }
                 }catch ( Throwable t ) {
                     log.error("",t);
-                    socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
+                    if (socket != null) {
+                        socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
+                    }
                 } finally {
                     if (launch) {
                         try {

Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1406788&r1=1406787&r2=1406788&view=diff
==============================================================================
--- tomcat/trunk/res/findbugs/filter-false-positives.xml (original)
+++ tomcat/trunk/res/findbugs/filter-false-positives.xml Wed Nov  7 20:16:19 2012
@@ -186,6 +186,19 @@
     <Bug code="ST" />
   </Match>
   <Match>
+    <!-- Node constructors add node to parent. Local variable is used to
+         silence an Eclipse warning -->
+    <Class name="org.apache.jasper.compiler.ELFunctionMapper"/>
+    <Method name="map"/>
+    <Bug code="DLS"/>
+  </Match>
+  <Match>
+    <!-- Node constructors add node to parent. Local variable is used to
+         silence an Eclipse warning -->
+    <Class name="org.apache.jasper.compiler.Parser"/>
+    <Bug code="DLS"/>
+  </Match>
+  <Match>
     <!-- Simpler to catch Exception than to create dummy implementations of the
          necessary exception hierarchy -->
     <Class name="org.apache.naming.factory.SendMailFactory$1" />
@@ -205,11 +218,6 @@
     <Bug code="Nm" />
   </Match>
   <Match>
-    <!-- Class has to implement clone since its superclass does but fakes it -->
-    <Class name="org.apache.naming.resources.ResourceAttributes" />
-    <Bug code="CN" />
-  </Match>
-  <Match>
     <!-- Use of == is deliberate -->
     <Class name="org.apache.tomcat.jdbc.pool.JdbcInterceptor" />
     <Method name="compare" />
@@ -288,6 +296,12 @@
     <Bug code="ML" />
   </Match>
   <Match>
+    <!-- Object is only ever set to null, sync therefore is still valid -->
+    <Class name="org.apache.tomcat.util.net.NioEndpoint$SocketProcessor"/>
+    <Method name="run"/>
+    <Bug code="ML"/>
+  </Match>
+  <Match>
     <Class name="org.apache.tomcat.util.net.SecureNioChannel"/>
     <Method name="rehandshake"/>
     <Bug code="DE" />

Modified: tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/AbstractTestTag.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/AbstractTestTag.java?rev=1406788&r1=1406787&r2=1406788&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/AbstractTestTag.java (original)
+++ tomcat/trunk/test/org/apache/jasper/tagplugins/jstl/core/AbstractTestTag.java Wed Nov
 7 20:16:19 2012
@@ -30,6 +30,7 @@ public abstract class AbstractTestTag ex
 
     @Before
     public void setup() throws Exception {
+        super.setUp();
         Tomcat tomcat = getTomcatInstance();
 
         File appDir = new File("test/webapp-3.0");



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


Mime
View raw message