admin@glassfish.java.net

CODE REVIEW: FindBugs: admin-ee/jes-mf

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Thu, 03 May 2007 12:12:41 -0700

TIMEOUT: 17:00 PST May 3
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2965

dpatil: com/sun/mfwk/agent/appserv/util/BundleReader.java:57:57 DE:
com.sun.mfwk.agent.appserv.util.BundleReader.setBundle(String) might
ignore java.lang.Exception (H)
dpatil: com/sun/mfwk/agent/appserv/util/BundleReader.java:64:64 DE:
com.sun.mfwk.agent.appserv.util.BundleReader.() might ignore
java.lang.Exception (H)
dpatil: com/sun/mfwk/agent/appserv/lifecycle/beans/ObjectName.java:
350:350 ES: Comparison of String parameter using == or != in
com.sun.mfwk.agent.appserv.lifecycle.beans.ObjectName.fetchPropertyByNam
e(String) (H)
dpatil: com/sun/mfwk/agent/appserv/lifecycle/beans/Notifications.java:
452:452 ES: Comparison of String parameter using == or != in
com.sun.mfwk.agent.appserv.lifecycle.beans.Notifications.fetchPropertyBy
Name(String) (H)
dpatil: com/sun/mfwk/agent/appserv/lifecycle/beans/Attribute.java:
184:184 ES: Comparison of String parameter using == or != in
com.sun.mfwk.agent.appserv.lifecycle.beans.Attribute.fetchPropertyByName
(String) (H)
dpatil: com/sun/mfwk/agent/appserv/lifecycle/beans/Mapping.java:
184:184 ES: Comparison of String parameter using == or != in
com.sun.mfwk.agent.appserv.lifecycle.beans.Mapping.fetchPropertyByName
(String) (H)
dpatil: com/sun/mfwk/agent/appserv/util/Constants.java:13:13 MS:
com.sun.mfwk.agent.appserv.util.Constants.CONNECTION_CREDENTIALS
isn't final but should be (H)


Index: admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/Notifications.java
===================================================================
RCS file: /cvs/glassfish/admin-ee/jes-mf/src/java/com/sun/mfwk/agent/
appserv/lifecycle/beans/Notifications.java,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 Notifications.java
--- admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/Notifications.java 18 Jan 2007 23:29:29 -0000 1.1.1.1
+++ admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/Notifications.java 3 May 2007 18:54:12 -0000
@@ -19,6 +19,7 @@
   * monitoringMbeanAttributeValue
<monitoring-mbean-attribute-value> : String
   *
   * @Generated
+ <b>NOT THREAD SAFE (mutable variables)</b>
   */
package com.sun.mfwk.agent.appserv.lifecycle.beans;
Index: admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/ObjectName.java
===================================================================
RCS file: /cvs/glassfish/admin-ee/jes-mf/src/java/com/sun/mfwk/agent/
appserv/lifecycle/beans/ObjectName.java,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 ObjectName.java
--- admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/ObjectName.java 18 Jan 2007 23:29:29 -0000 1.1.1.1
+++ admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/lifecycle/
beans/ObjectName.java 3 May 2007 18:54:12 -0000
@@ -5,18 +5,19 @@
   *
   * Generated on Sun Aug 28 23:45:36 PDT 2005
   * @Generated
+ <b>NOT THREAD SAFE (mutable variables)</b>
   */
package com.sun.mfwk.agent.appserv.lifecycle.beans;
-public class ObjectName {
+public final class ObjectName {
         public static final String MONITORINGMBEANNAMETEMPLATE =
"MonitoringMbeanNameTemplate"; // NOI18N
         public static final String ATTRIBUTE = "Attribute"; //
NOI18N
         public static final String MAPPING = "Mapping"; // NOI18N
         private java.lang.String _MonitoringMbeanNameTemplate;
- private java.util.List _Attribute = new java.util.ArrayList
(); // List<Attribute>
- private java.util.List _Mapping = new java.util.ArrayList
(); // List<Mapping>
+ private final java.util.List _Attribute = new
java.util.ArrayList(); // List<Attribute>
+ private final java.util.List _Mapping = new
java.util.ArrayList(); // List<Mapping>
         /**
          * Normal starting point constructor.
@@ -346,12 +347,17 @@
                         throw new IllegalArgumentException(name+" is
not a valid property name for ObjectName");
         }
- public Object fetchPropertyByName(String name) {
- if (name == "monitoringMbeanNameTemplate")
+ public Object fetchPropertyByName(final String nameIn) {
+ if ( nameIn == null ) {
+ throw new IllegalArgumentException();
+ }
+ final String name = nameIn.intern();
+
+ if ( "monitoringMbeanNameTemplate".equals(name))
                         return getMonitoringMbeanNameTemplate();
- if (name == "attribute[]")
+ if ( "attribute[]".equals(name))
                         return getAttribute();
- if (name == "mapping[]")
+ if ( "mapping[]".equals(name))
                         return getMapping();
                 throw new IllegalArgumentException(name+" is not a
valid property name for ObjectName");
         }


===================================================================
RCS file: /cvs/glassfish/tools/src/java/com/sun/enterprise/tools/
common/validation/util/BundleReader.java,v
retrieving revision 1.3
diff -w -u -r1.3 BundleReader.java
--- tools/src/java/com/sun/enterprise/tools/common/validation/util/
BundleReader.java 25 Dec 2005 04:28:26 -0000 1.3
+++ tools/src/java/com/sun/enterprise/tools/common/validation/util/
BundleReader.java 3 May 2007 18:54:14 -0000
@@ -43,6 +43,7 @@
   *
   * @author Rajeshwar Patil
   * @version %I%, %G%
+ <b>NOT THREAD SAFE: mutable 'resourceBundle'</b>
   */
public class BundleReader {
@@ -56,6 +57,9 @@
      public BundleReader() {
      }
+ private static void IGNORE_EXCEPTION(final Exception e ) {
+ // ignore
+ }
      /**
       * Gets the value of the the given <code>key</code> from the
bundle
       *
@@ -68,6 +72,7 @@
          try {
              return resourceBundle.getString(key);
          } catch (MissingResourceException missingResourceException) {
+ IGNORE_EXCEPTION(missingResourceException);
              return key;
          }
      }
@@ -79,13 +84,17 @@
      public static void setBundle(String bundleFile){
          try {
              resourceBundle = ResourceBundle.getBundle(bundleFile);
- } catch (Exception ex) { }
+ } catch (Exception ex) {
+ IGNORE_EXCEPTION(ex);
+ }
      }

      static {
          try {
              resourceBundle = ResourceBundle.getBundle
(Constants.BUNDLE_FILE);
- } catch (Exception ex) { }
+ } catch (Exception ex) {
+ IGNORE_EXCEPTION(ex);
+ }
      }
}

Index: admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/util/
Constants.java
===================================================================
RCS file: /cvs/glassfish/admin-ee/jes-mf/src/java/com/sun/mfwk/agent/
appserv/util/Constants.java,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 Constants.java
--- admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/util/
Constants.java 18 Jan 2007 23:29:29 -0000 1.1.1.1
+++ admin-ee/jes-mf/src/java/com/sun/mfwk/agent/appserv/util/
Constants.java 3 May 2007 18:54:12 -0000
@@ -7,10 +7,10 @@
/**
   * Constants used in JES MF plugin.
   */
-public class Constants {
+public final class Constants {
      /** Connection credential property name */
- public static String CONNECTION_CREDENTIALS =
"ConnectionCredentials";
+ public static final String CONNECTION_CREDENTIALS =
"ConnectionCredentials";
      /** Key used for admin user */
      public static final String USER_KEY = "user";