diff options
author | Robert Gemmell <robbie@apache.org> | 2010-09-19 16:59:50 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2010-09-19 16:59:50 +0000 |
commit | 169777a63ef8c8575533df068c674bdfe40ec405 (patch) | |
tree | aa07361522c96d42bfdf7e276e1913070dd1e5ac /java/management/common/src | |
parent | 624611189a22a4b4616da635dcdd689abf96f6c7 (diff) | |
download | qpid-python-169777a63ef8c8575533df068c674bdfe40ec405.tar.gz |
QPID-2857: address a further 60 or so issues identified by running FindBugs across the Java codebase
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@998700 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/common/src')
6 files changed, 64 insertions, 32 deletions
diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java b/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java index c03b782987..40202c2679 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java @@ -137,7 +137,7 @@ public class JMXConnnectionFactory { Map<String, Object> env = new HashMap<String, Object>(); JMXServiceURL jmxUrl = null; - if (connectionType == "RMI") + if (connectionType.equalsIgnoreCase("RMI")) { jmxUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"); @@ -167,7 +167,7 @@ public class JMXConnnectionFactory { * jmxremote.sasl plugin (from the jmxremote_optional.jar) */ env.put("jmx.remote.protocol.provider.pkgs", "com.sun.jmx.remote.protocol"); - if (connectionType == "JMXMP_CRAM-MD5") + if (connectionType.equalsIgnoreCase("JMXMP_CRAM-MD5")) { Map<String, Class<? extends SaslClientFactory>> map = new HashMap<String, Class<? extends SaslClientFactory>>(); map.put("CRAM-MD5-HASHED", CRAMMD5HashedSaslClientFactory.class); @@ -178,7 +178,7 @@ public class JMXConnnectionFactory { env.put("jmx.remote.profiles", Constants.SASL_CRAMMD5); env.put("jmx.remote.sasl.callback.handler", handler); } - else if (connectionType == "JMXMP_PLAIN") + else if (connectionType.equalsIgnoreCase("JMXMP_PLAIN")) { Security.addProvider(new SaslProvider()); CallbackHandler handler = new UserPasswordCallbackHandler(userName, password); @@ -233,9 +233,15 @@ public class JMXConnnectionFactory { { try { - _jmxc = null; - _connectionRetrieved = false; - _connectionException = null; + synchronized (this) + { + if(_connectionRetrieved) + { + _jmxc = null; + _connectionRetrieved = false; + _connectionException = null; + } + } JMXConnector conn = JMXConnectorFactory.connect(_jmxUrl, _env); diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java index dfdd43ba1a..6d15869f0c 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java @@ -21,6 +21,9 @@ package org.apache.qpid.management.common.mbeans; import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.apache.qpid.management.common.mbeans.annotations.MBeanAttribute; import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation; @@ -38,10 +41,12 @@ public interface LoggingManagement String TYPE = "LoggingManagement"; //TabularType and contained CompositeType key/description information - //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. - String[] COMPOSITE_ITEM_NAMES = {"LoggerName", "Level"}; - String[] COMPOSITE_ITEM_DESCRIPTIONS = {"Name of the logger", "Level of the logger"}; - String[] TABULAR_UNIQUE_INDEX = {COMPOSITE_ITEM_NAMES[0]}; + //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. + String LOGGER_NAME = "LoggerName"; + String LOGGER_LEVEL = "Level"; + List<String> COMPOSITE_ITEM_NAMES = Collections.unmodifiableList(Arrays.asList(LOGGER_NAME, LOGGER_LEVEL)); + List<String> COMPOSITE_ITEM_DESCRIPTIONS = Collections.unmodifiableList(Arrays.asList("Name of the logger", "Level of the logger")); + List<String> TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(LOGGER_NAME)); /** * Attribute to represent the log4j xml configuration file's LogWatch interval. diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedConnection.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedConnection.java index ff096aa22b..d6b79d1dde 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedConnection.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedConnection.java @@ -22,8 +22,10 @@ package org.apache.qpid.management.common.mbeans; import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; import java.util.Date; -import java.security.Principal; +import java.util.List; import javax.management.JMException; import javax.management.MBeanOperationInfo; @@ -45,9 +47,13 @@ public interface ManagedConnection //TabularType and contained CompositeType key/description information //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. //"Flow Blocked" added in Qpid JMX API 1.5 - String[] COMPOSITE_ITEM_NAMES = {"Channel Id", "Transactional", "Default Queue", "Unacknowledged Message Count", "Flow Blocked"}; - String[] COMPOSITE_ITEM_DESCRIPTIONS = {"Channel Id", "Transactional", "Default Queue", "Unacknowledged Message Count", "Flow Blocked"}; - String[] TABULAR_UNIQUE_INDEX = {COMPOSITE_ITEM_NAMES[0]}; + String CHAN_ID = "Channel Id"; + String TRANSACTIONAL = "Transactional"; + String DEFAULT_QUEUE = "Default Queue"; + String UNACKED_COUNT = "Unacknowledged Message Count"; + String FLOW_BLOCKED = "Flow Blocked"; + List<String> COMPOSITE_ITEM_NAMES_DESC = Collections.unmodifiableList(Arrays.asList(CHAN_ID, TRANSACTIONAL, DEFAULT_QUEUE, UNACKED_COUNT, FLOW_BLOCKED)); + List<String> TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(CHAN_ID)); @MBeanAttribute(name = "ClientId", description = "Client Id") String getClientId(); diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedExchange.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedExchange.java index 970f5913d5..78a1eb964f 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedExchange.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedExchange.java @@ -49,17 +49,17 @@ public interface ManagedExchange List<String> COMPOSITE_ITEM_NAMES = Collections.unmodifiableList(Arrays.asList(BINDING_KEY, QUEUE_NAMES)); List<String> COMPOSITE_ITEM_DESCRIPTIONS = Collections.unmodifiableList(Arrays.asList(BINDING_KEY, QUEUE_NAMES)); - String[] TABULAR_UNIQUE_INDEX = {BINDING_KEY}; + List<String> TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(BINDING_KEY)); //TabularType and contained CompositeType key/description info for HEADERS exchange only. //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. - String BINDING_NUMBER = "Binding No"; - String QUEUE_NAME = "Queue Name"; - String QUEUE_BINDINGS = "Queue Bindings"; + String HDR_BINDING_NUMBER = "Binding No"; + String HDR_QUEUE_NAME = "Queue Name"; + String HDR_QUEUE_BINDINGS = "Queue Bindings"; - String[] HEADERS_COMPOSITE_ITEM_NAMES = new String[]{BINDING_NUMBER, QUEUE_NAME, QUEUE_BINDINGS}; - String[] HEADERS_COMPOSITE_ITEM_DESC = new String[]{BINDING_NUMBER, QUEUE_NAME, QUEUE_BINDINGS}; - String[] HEADERS_TABULAR_UNIQUE_INDEX = new String[]{BINDING_NUMBER}; + List<String> HEADERS_COMPOSITE_ITEM_NAMES = Collections.unmodifiableList(Arrays.asList(HDR_BINDING_NUMBER, HDR_QUEUE_NAME, HDR_QUEUE_BINDINGS)); + List<String> HEADERS_COMPOSITE_ITEM_DESC = Collections.unmodifiableList(Arrays.asList(HDR_BINDING_NUMBER, HDR_QUEUE_NAME, HDR_QUEUE_BINDINGS)); + List<String> HEADERS_TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(HDR_BINDING_NUMBER)); /** * Returns the name of the managed exchange. diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java index 7d61d32f71..be31d8ef88 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java @@ -45,14 +45,20 @@ public interface ManagedQueue //TabularType and contained CompositeType key/description information for message list //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. //"Queue Position" added in Qpid JMX API 1.3 - String[] VIEW_MSGS_COMPOSITE_ITEM_NAMES = {"AMQ MessageId", "Header", "Size(bytes)", "Redelivered", "Queue Position"}; - String[] VIEW_MSGS_COMPOSITE_ITEM_DESCRIPTIONS = {"AMQ MessageId", "Header", "Size(bytes)", "Redelivered", "Queue Position"}; - String[] VIEW_MSGS_TABULAR_UNIQUE_INDEX = {VIEW_MSGS_COMPOSITE_ITEM_NAMES[0]}; - + String MSG_AMQ_ID = "AMQ MessageId"; + String MSG_HEADER = "Header"; + String MSG_SIZE = "Size(bytes)"; + String MSG_REDELIVERED = "Redelivered"; + String MSG_QUEUE_POS = "Queue Position"; + List<String> VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC = Collections.unmodifiableList(Arrays.asList(MSG_AMQ_ID, MSG_HEADER, MSG_SIZE, MSG_REDELIVERED, MSG_QUEUE_POS)); + List<String> VIEW_MSGS_TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(MSG_QUEUE_POS)); + //CompositeType key/description information for message content - //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. - String[] VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES = { "AMQ MessageId", "MimeType", "Encoding", "Content" }; - String[] VIEW_MSG_CONTENT_COMPOSITE_ITEM_DESCRIPTIONS = { "AMQ MessageId", "MimeType", "Encoding", "Content" }; + //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. + String MIME = "MimeType"; + String ENCODING = "Encoding"; + String CONTENT = "Content"; + List<String> VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC = Collections.unmodifiableList(Arrays.asList(MSG_AMQ_ID, MIME, ENCODING, CONTENT)); //Individual attribute name constants static final String ATTR_NAME = "Name"; diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java index d83d534428..2bd00d5802 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java @@ -20,6 +20,10 @@ */ package org.apache.qpid.management.common.mbeans; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation; import org.apache.qpid.management.common.mbeans.annotations.MBeanOperationParameter; @@ -33,12 +37,17 @@ public interface UserManagement //TabularType and contained CompositeType key/description information. //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. - String[] COMPOSITE_ITEM_NAMES = {"Username", "read", "write", "admin"}; - String[] COMPOSITE_ITEM_DESCRIPTIONS = {"Broker Login username", + String USERNAME = "Username"; + String RIGHTS_READ_ONLY = "read"; + String RIGHTS_READ_WRITE = "write"; + String RIGHTS_ADMIN = "admin"; + List<String> COMPOSITE_ITEM_NAMES = Collections.unmodifiableList(Arrays.asList(USERNAME, RIGHTS_READ_ONLY, RIGHTS_READ_WRITE, RIGHTS_ADMIN)); + List<String> COMPOSITE_ITEM_DESCRIPTIONS = Collections.unmodifiableList( + Arrays.asList("Broker Login username", "Management Console Read Permission", "Management Console Write Permission", - "Management Console Admin Permission"}; - String[] TABULAR_UNIQUE_INDEX = {COMPOSITE_ITEM_NAMES[0]}; + "Management Console Admin Permission")); + List<String> TABULAR_UNIQUE_INDEX = Collections.unmodifiableList(Arrays.asList(USERNAME)); //********** Operations *****************// /** |