提交 8580fa1f 编写于 作者: T tbell

Merge

...@@ -233,7 +233,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -233,7 +233,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException { NotCompliantMBeanException, InstanceNotFoundException {
ObjectName logicalName = name;
Class theClass; Class theClass;
if (className == null) { if (className == null) {
...@@ -519,8 +518,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -519,8 +518,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
QueryExp query) { QueryExp query) {
// Query the MBeans on the repository // Query the MBeans on the repository
// //
Set<NamedObject> list = null; Set<NamedObject> list = repository.query(name, query);
list = repository.query(name, query);
if (queryByRepo) { if (queryByRepo) {
// The repository performs the filtering // The repository performs the filtering
...@@ -576,8 +574,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -576,8 +574,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
private Set<ObjectName> queryNamesImpl(ObjectName name, QueryExp query) { private Set<ObjectName> queryNamesImpl(ObjectName name, QueryExp query) {
// Query the MBeans on the repository // Query the MBeans on the repository
// //
Set<NamedObject> list = null; Set<NamedObject> list = repository.query(name, query);
list = repository.query(name, query);
if (queryByRepo) { if (queryByRepo) {
// The repository performs the filtering // The repository performs the filtering
...@@ -1042,7 +1039,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -1042,7 +1039,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
if (registerFailed && moi instanceof DynamicMBean2) if (registerFailed && moi instanceof DynamicMBean2)
((DynamicMBean2) moi).registerFailed(); ((DynamicMBean2) moi).registerFailed();
try { try {
moi.postRegister(new Boolean(registrationDone)); moi.postRegister(registrationDone);
} catch (RuntimeException e) { } catch (RuntimeException e) {
throw new RuntimeMBeanException(e, throw new RuntimeMBeanException(e,
"RuntimeException thrown in postRegister method"); "RuntimeException thrown in postRegister method");
...@@ -1094,8 +1091,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -1094,8 +1091,7 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
IllegalArgumentException("Object name cannot be null"), IllegalArgumentException("Object name cannot be null"),
"Exception occurred trying to get an MBean"); "Exception occurred trying to get an MBean");
} }
DynamicMBean obj = null; DynamicMBean obj = repository.retrieve(name);
obj = repository.retrieve(name);
if (obj == null) { if (obj == null) {
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER, MBEANSERVER_LOGGER.logp(Level.FINER,
...@@ -1568,7 +1564,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -1568,7 +1564,6 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
query.setMBeanServer(server); query.setMBeanServer(server);
try { try {
for (NamedObject no : list) { for (NamedObject no : list) {
final DynamicMBean obj = no.getObject();
boolean res; boolean res;
try { try {
res = query.apply(no.getName()); res = query.apply(no.getName());
......
...@@ -205,7 +205,7 @@ public class MBeanInstantiator { ...@@ -205,7 +205,7 @@ public class MBeanInstantiator {
*/ */
public Object instantiate(Class theClass) public Object instantiate(Class theClass)
throws ReflectionException, MBeanException { throws ReflectionException, MBeanException {
Object moi = null; Object moi;
// ------------------------------ // ------------------------------
...@@ -265,7 +265,7 @@ public class MBeanInstantiator { ...@@ -265,7 +265,7 @@ public class MBeanInstantiator {
// ------------------------------ // ------------------------------
// ------------------------------ // ------------------------------
final Class[] tab; final Class[] tab;
Object moi= null; Object moi;
try { try {
// Build the signature of the method // Build the signature of the method
// //
...@@ -283,8 +283,7 @@ public class MBeanInstantiator { ...@@ -283,8 +283,7 @@ public class MBeanInstantiator {
} }
// Query the metadata service to get the right constructor // Query the metadata service to get the right constructor
Constructor cons = null; Constructor cons = findConstructor(theClass, tab);
cons = findConstructor(theClass, tab);
if (cons == null) { if (cons == null) {
throw new ReflectionException(new throw new ReflectionException(new
...@@ -408,7 +407,7 @@ public class MBeanInstantiator { ...@@ -408,7 +407,7 @@ public class MBeanInstantiator {
throw new RuntimeOperationsException(new throw new RuntimeOperationsException(new
IllegalArgumentException(), "Null className passed in parameter"); IllegalArgumentException(), "Null className passed in parameter");
} }
Class theClass = null; Class theClass;
if (loaderName == null) { if (loaderName == null) {
// Load the class using the agent class loader // Load the class using the agent class loader
theClass = findClass(className, loader); theClass = findClass(className, loader);
...@@ -621,7 +620,7 @@ public class MBeanInstantiator { ...@@ -621,7 +620,7 @@ public class MBeanInstantiator {
static Class loadClass(String className, ClassLoader loader) static Class loadClass(String className, ClassLoader loader)
throws ReflectionException { throws ReflectionException {
Class theClass = null; Class theClass;
if (className == null) { if (className == null) {
throw new RuntimeOperationsException(new throw new RuntimeOperationsException(new
IllegalArgumentException("The class name cannot be null"), IllegalArgumentException("The class name cannot be null"),
......
...@@ -89,7 +89,6 @@ public class Repository { ...@@ -89,7 +89,6 @@ public class Repository {
/* This class is used to match an ObjectName against a pattern. */ /* This class is used to match an ObjectName against a pattern. */
private final static class ObjectNamePattern { private final static class ObjectNamePattern {
private final char[] domain;
private final String[] keys; private final String[] keys;
private final String[] values; private final String[] values;
private final String properties; private final String properties;
...@@ -106,8 +105,7 @@ public class Repository { ...@@ -106,8 +105,7 @@ public class Repository {
* @param pattern The ObjectName pattern under examination. * @param pattern The ObjectName pattern under examination.
**/ **/
public ObjectNamePattern(ObjectName pattern) { public ObjectNamePattern(ObjectName pattern) {
this(pattern.getDomain(), this(pattern.isPropertyListPattern(),
pattern.isPropertyListPattern(),
pattern.isPropertyValuePattern(), pattern.isPropertyValuePattern(),
pattern.getCanonicalKeyPropertyListString(), pattern.getCanonicalKeyPropertyListString(),
pattern.getKeyPropertyList(), pattern.getKeyPropertyList(),
...@@ -124,13 +122,11 @@ public class Repository { ...@@ -124,13 +122,11 @@ public class Repository {
* @param keyPropertyList pattern.getKeyPropertyList(). * @param keyPropertyList pattern.getKeyPropertyList().
* @param pattern The ObjectName pattern under examination. * @param pattern The ObjectName pattern under examination.
**/ **/
ObjectNamePattern(String domain, ObjectNamePattern(boolean propertyListPattern,
boolean propertyListPattern,
boolean propertyValuePattern, boolean propertyValuePattern,
String canonicalProps, String canonicalProps,
Map<String,String> keyPropertyList, Map<String,String> keyPropertyList,
ObjectName pattern) { ObjectName pattern) {
this.domain = domain.toCharArray();
this.isPropertyListPattern = propertyListPattern; this.isPropertyListPattern = propertyListPattern;
this.isPropertyValuePattern = propertyValuePattern; this.isPropertyValuePattern = propertyValuePattern;
this.properties = canonicalProps; this.properties = canonicalProps;
...@@ -538,7 +534,7 @@ public class Repository { ...@@ -538,7 +534,7 @@ public class Repository {
// "domain:*", "domain:[key=value],*" : names in the specified domain // "domain:*", "domain:[key=value],*" : names in the specified domain
// Surely one of the most frequent case ... query on the whole world // Surely one of the most frequent case ... query on the whole world
ObjectName name = null; ObjectName name;
if (pattern == null || if (pattern == null ||
pattern.getCanonicalName().length() == 0 || pattern.getCanonicalName().length() == 0 ||
pattern.equals(ObjectName.WILDCARD)) pattern.equals(ObjectName.WILDCARD))
...@@ -660,7 +656,7 @@ public class Repository { ...@@ -660,7 +656,7 @@ public class Repository {
* @return Number of MBeans. * @return Number of MBeans.
*/ */
public Integer getCount() { public Integer getCount() {
return new Integer(nbElements); return nbElements;
} }
/** /**
...@@ -669,7 +665,7 @@ public class Repository { ...@@ -669,7 +665,7 @@ public class Repository {
* *
* @return A string giving the name of the default domain name. * @return A string giving the name of the default domain name.
*/ */
public String getDefaultDomain() { public String getDefaultDomain() {
return domain; return domain;
} }
......
...@@ -435,7 +435,6 @@ public abstract class ClientNotifForwarder { ...@@ -435,7 +435,6 @@ public abstract class ClientNotifForwarder {
clientSequenceNumber = nr.getNextSequenceNumber(); clientSequenceNumber = nr.getNextSequenceNumber();
final int size = infoList.size();
listeners = new HashMap<Integer, ClientListenerInfo>(); listeners = new HashMap<Integer, ClientListenerInfo>();
for (int i = 0 ; i < len ; i++) { for (int i = 0 ; i < len ; i++) {
...@@ -792,9 +791,6 @@ public abstract class ClientNotifForwarder { ...@@ -792,9 +791,6 @@ public abstract class ClientNotifForwarder {
private Thread currentFetchThread; private Thread currentFetchThread;
// admin stuff
private boolean inited = false;
// state // state
/** /**
* This state means that a thread is being created for fetching and forwarding notifications. * This state means that a thread is being created for fetching and forwarding notifications.
......
...@@ -269,7 +269,7 @@ public class ServerNotifForwarder { ...@@ -269,7 +269,7 @@ public class ServerNotifForwarder {
", the maxNotifications is " + maxNotifications); ", the maxNotifications is " + maxNotifications);
} }
NotificationResult nr = null; NotificationResult nr;
final long t = Math.min(connectionTimeout, timeout); final long t = Math.min(connectionTimeout, timeout);
try { try {
nr = notifBuffer.fetchNotifications(bufferFilter, nr = notifBuffer.fetchNotifications(bufferFilter,
...@@ -322,7 +322,7 @@ public class ServerNotifForwarder { ...@@ -322,7 +322,7 @@ public class ServerNotifForwarder {
private Integer getListenerID() { private Integer getListenerID() {
synchronized(listenerCounterLock) { synchronized(listenerCounterLock) {
return new Integer(listenerCounter++); return listenerCounter++;
} }
} }
...@@ -336,7 +336,7 @@ public class ServerNotifForwarder { ...@@ -336,7 +336,7 @@ public class ServerNotifForwarder {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
AccessControlContext acc = AccessController.getContext(); AccessControlContext acc = AccessController.getContext();
ObjectInstance oi = null; ObjectInstance oi;
try { try {
oi = AccessController.doPrivileged( oi = AccessController.doPrivileged(
new PrivilegedExceptionAction<ObjectInstance>() { new PrivilegedExceptionAction<ObjectInstance>() {
......
...@@ -437,7 +437,7 @@ public class FileLoginModule implements LoginModule { ...@@ -437,7 +437,7 @@ public class FileLoginModule implements LoginModule {
// get the username and password // get the username and password
getUsernamePassword(usePasswdFromSharedState); getUsernamePassword(usePasswdFromSharedState);
String localPassword = null; String localPassword;
// userCredentials is initialized in login() // userCredentials is initialized in login()
if (((localPassword = userCredentials.getProperty(username)) == null) || if (((localPassword = userCredentials.getProperty(username)) == null) ||
...@@ -487,10 +487,14 @@ public class FileLoginModule implements LoginModule { ...@@ -487,10 +487,14 @@ public class FileLoginModule implements LoginModule {
throw ace; throw ace;
} }
} }
BufferedInputStream bis = new BufferedInputStream(fis); try {
userCredentials = new Properties(); BufferedInputStream bis = new BufferedInputStream(fis);
userCredentials.load(bis); userCredentials = new Properties();
bis.close(); userCredentials.load(bis);
bis.close();
} finally {
fis.close();
}
} }
/** /**
......
...@@ -295,7 +295,7 @@ private final class JMXCallbackHandler implements CallbackHandler { ...@@ -295,7 +295,7 @@ private final class JMXCallbackHandler implements CallbackHandler {
private static class FileLoginConfig extends Configuration { private static class FileLoginConfig extends Configuration {
// The JAAS configuration for file-based authentication // The JAAS configuration for file-based authentication
private static AppConfigurationEntry[] entries; private AppConfigurationEntry[] entries;
// The classname of the login module for file-based authentication // The classname of the login module for file-based authentication
private static final String FILE_LOGIN_MODULE = private static final String FILE_LOGIN_MODULE =
......
...@@ -231,10 +231,13 @@ public class MBeanServerFileAccessController ...@@ -231,10 +231,13 @@ public class MBeanServerFileAccessController
private static Properties propertiesFromFile(String fname) private static Properties propertiesFromFile(String fname)
throws IOException { throws IOException {
FileInputStream fin = new FileInputStream(fname); FileInputStream fin = new FileInputStream(fname);
Properties p = new Properties(); try {
p.load(fin); Properties p = new Properties();
fin.close(); p.load(fin);
return p; return p;
} finally {
fin.close();
}
} }
private void checkAccessLevel(String accessLevel) { private void checkAccessLevel(String accessLevel) {
......
...@@ -83,7 +83,7 @@ class NumericValueExp extends QueryEval implements ValueExp { ...@@ -83,7 +83,7 @@ class NumericValueExp extends QueryEval implements ValueExp {
* <p>The <b>serialVersionUID</b> of this class is <code>-4679739485102359104L</code>. * <p>The <b>serialVersionUID</b> of this class is <code>-4679739485102359104L</code>.
*/ */
private static final ObjectStreamField[] serialPersistentFields; private static final ObjectStreamField[] serialPersistentFields;
private Number val = new Double(0); private Number val = 0.0;
private static boolean compat = false; private static boolean compat = false;
static { static {
...@@ -213,11 +213,11 @@ class NumericValueExp extends QueryEval implements ValueExp { ...@@ -213,11 +213,11 @@ class NumericValueExp extends QueryEval implements ValueExp {
} }
if (isLong) if (isLong)
{ {
this.val = new Long(longVal); this.val = longVal;
} }
else else
{ {
this.val = new Double(doubleVal); this.val = doubleVal;
} }
} }
else else
......
...@@ -449,7 +449,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp { ...@@ -449,7 +449,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
// parses domain part // parses domain part
domain_parsing: domain_parsing:
while (index < len) { while (index < len) {
switch (c = name_chars[index]) { switch (name_chars[index]) {
case ':' : case ':' :
_domain_length = index++; _domain_length = index++;
break domain_parsing; break domain_parsing;
...@@ -619,7 +619,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp { ...@@ -619,7 +619,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
case '\n' : case '\n' :
final String ichar = ((c1=='\n')?"\\n":""+c1); final String ichar = ((c1=='\n')?"\\n":""+c1);
throw new MalformedObjectNameException( throw new MalformedObjectNameException(
"Invalid character '" + c1 + "Invalid character '" + ichar +
"' in value part of property"); "' in value part of property");
default : default :
in_index++; in_index++;
......
...@@ -750,7 +750,7 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration { ...@@ -750,7 +750,7 @@ public class StandardMBean implements DynamicMBean, MBeanRegistration {
* @return the Descriptor for the new MBeanInfo. * @return the Descriptor for the new MBeanInfo.
*/ */
Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) { Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) {
ImmutableDescriptor desc = null; ImmutableDescriptor desc;
if (info == null || if (info == null ||
info.getDescriptor() == null || info.getDescriptor() == null ||
info.getDescriptor().getFieldNames().length == 0) { info.getDescriptor().getFieldNames().length == 0) {
......
...@@ -591,8 +591,8 @@ public class MLet extends java.net.URLClassLoader ...@@ -591,8 +591,8 @@ public class MLet extends java.net.URLClassLoader
// Instantiate the class specified in the // Instantiate the class specified in the
// CODE or OBJECT section of the MLet tag // CODE or OBJECT section of the MLet tag
// //
Object o = null; Object o;
ObjectInstance objInst = null; ObjectInstance objInst;
if (code != null && serName != null) { if (code != null && serName != null) {
final String msg = final String msg =
...@@ -1131,11 +1131,17 @@ public class MLet extends java.net.URLClassLoader ...@@ -1131,11 +1131,17 @@ public class MLet extends java.net.URLClassLoader
return null; return null;
} finally { } finally {
// Cleanup ... // Cleanup ...
if (tmpFile!=null) try { if (tmpFile!=null) {
tmpFile.delete(); try {
} catch (Exception x) { boolean deleted = tmpFile.delete();
MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), if (!deleted) {
"getTmpDir", "Failed to delete temporary file", x); MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
"getTmpDir", "Failed to delete temp file");
}
} catch (Exception x) {
MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
"getTmpDir", "Failed to delete temporary file", x);
}
} }
} }
} }
...@@ -1178,25 +1184,8 @@ public class MLet extends java.net.URLClassLoader ...@@ -1178,25 +1184,8 @@ public class MLet extends java.net.URLClassLoader
* Removes any white space from a string. This is used to * Removes any white space from a string. This is used to
* convert strings such as "Windows NT" to "WindowsNT". * convert strings such as "Windows NT" to "WindowsNT".
*/ */
private String removeSpace(String s) { private static String removeSpace(String s) {
s = s.trim(); return s.trim().replace(" ", "");
int j = s.indexOf(' ');
if (j == -1) {
return s;
}
String temp = "";
int k = 0;
while (j != -1) {
s = s.substring(k);
j = s.indexOf(' ');
if (j != -1) {
temp = temp + s.substring(0, j);
} else {
temp = temp + s.substring(0);
}
k = j + 1;
}
return temp;
} }
/** /**
......
...@@ -240,14 +240,12 @@ class MLetParser { ...@@ -240,14 +240,12 @@ class MLetParser {
MLET_LOGGER.logp(Level.FINER, MLET_LOGGER.logp(Level.FINER,
MLetParser.class.getName(), MLetParser.class.getName(),
mth, requiresCodeWarning); mth, requiresCodeWarning);
atts = null;
throw new IOException(requiresCodeWarning); throw new IOException(requiresCodeWarning);
} }
if (atts.get("archive") == null) { if (atts.get("archive") == null) {
MLET_LOGGER.logp(Level.FINER, MLET_LOGGER.logp(Level.FINER,
MLetParser.class.getName(), MLetParser.class.getName(),
mth, requiresJarsWarning); mth, requiresJarsWarning);
atts = null;
throw new IOException(requiresJarsWarning); throw new IOException(requiresJarsWarning);
} }
} }
...@@ -265,7 +263,7 @@ class MLetParser { ...@@ -265,7 +263,7 @@ class MLetParser {
public List<MLetContent> parseURL(String urlname) throws IOException { public List<MLetContent> parseURL(String urlname) throws IOException {
// Parse the document // Parse the document
// //
URL url = null; URL url;
if (urlname.indexOf(':') <= 1) { if (urlname.indexOf(':') <= 1) {
String userDir = System.getProperty("user.dir"); String userDir = System.getProperty("user.dir");
String prot; String prot;
......
...@@ -591,8 +591,6 @@ public class DescriptorSupport ...@@ -591,8 +591,6 @@ public class DescriptorSupport
Set returnedSet = descriptorMap.entrySet(); Set returnedSet = descriptorMap.entrySet();
int i = 0; int i = 0;
Object currValue = null;
Map.Entry currElement = null;
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
MODELMBEAN_LOGGER.logp(Level.FINEST, MODELMBEAN_LOGGER.logp(Level.FINEST,
...@@ -600,7 +598,7 @@ public class DescriptorSupport ...@@ -600,7 +598,7 @@ public class DescriptorSupport
"getFields()", "Returning " + numberOfEntries + " fields"); "getFields()", "Returning " + numberOfEntries + " fields");
} }
for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) { for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) {
currElement = (Map.Entry) iter.next(); Map.Entry currElement = (Map.Entry) iter.next();
if (currElement == null) { if (currElement == null) {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
...@@ -609,7 +607,7 @@ public class DescriptorSupport ...@@ -609,7 +607,7 @@ public class DescriptorSupport
"getFields()", "Element is null"); "getFields()", "Element is null");
} }
} else { } else {
currValue = currElement.getValue(); Object currValue = currElement.getValue();
if (currValue == null) { if (currValue == null) {
responseFields[i] = currElement.getKey() + "="; responseFields[i] = currElement.getKey() + "=";
} else { } else {
...@@ -1127,7 +1125,7 @@ public class DescriptorSupport ...@@ -1127,7 +1125,7 @@ public class DescriptorSupport
final char c = entities[i].charAt(0); final char c = entities[i].charAt(0);
final String entity = entities[i].substring(1); final String entity = entities[i].substring(1);
charToEntityMap[c] = entity; charToEntityMap[c] = entity;
entityToCharMap.put(entity, new Character(c)); entityToCharMap.put(entity, c);
} }
} }
...@@ -1325,13 +1323,11 @@ public class DescriptorSupport ...@@ -1325,13 +1323,11 @@ public class DescriptorSupport
// utility to convert to int, returns -2 if bogus. // utility to convert to int, returns -2 if bogus.
private long toNumeric(String inStr) { private long toNumeric(String inStr) {
long result = -2;
try { try {
result = java.lang.Long.parseLong(inStr); return java.lang.Long.parseLong(inStr);
} catch (Exception e) { } catch (Exception e) {
return -2; return -2;
} }
return result;
} }
......
...@@ -432,7 +432,7 @@ public class ModelMBeanAttributeInfo ...@@ -432,7 +432,7 @@ public class ModelMBeanAttributeInfo
*/ */
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone = null; Descriptor clone;
if (in == null) { if (in == null) {
clone = new DescriptorSupport(); clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
......
...@@ -393,7 +393,7 @@ public class ModelMBeanConstructorInfo ...@@ -393,7 +393,7 @@ public class ModelMBeanConstructorInfo
* @exception RuntimeOperationsException if Descriptor is invalid * @exception RuntimeOperationsException if Descriptor is invalid
*/ */
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone = null; Descriptor clone;
if (in == null) { if (in == null) {
clone = new DescriptorSupport(); clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
......
...@@ -944,7 +944,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { ...@@ -944,7 +944,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
* @exception RuntimeOperationsException if Descriptor is invalid * @exception RuntimeOperationsException if Descriptor is invalid
*/ */
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone = null; Descriptor clone;
if (in == null) { if (in == null) {
clone = new DescriptorSupport(); clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
......
...@@ -328,7 +328,7 @@ public class ModelMBeanNotificationInfo ...@@ -328,7 +328,7 @@ public class ModelMBeanNotificationInfo
* @exception RuntimeOperationsException if Descriptor is invalid * @exception RuntimeOperationsException if Descriptor is invalid
*/ */
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone = null; Descriptor clone;
if (in == null) { if (in == null) {
clone = new DescriptorSupport(); clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
......
...@@ -424,7 +424,7 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo ...@@ -424,7 +424,7 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo
*/ */
private Descriptor validDescriptor(final Descriptor in) private Descriptor validDescriptor(final Descriptor in)
throws RuntimeOperationsException { throws RuntimeOperationsException {
Descriptor clone = null; Descriptor clone;
if (in == null) { if (in == null) {
clone = new DescriptorSupport(); clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
......
...@@ -1425,9 +1425,7 @@ public class RequiredModelMBean ...@@ -1425,9 +1425,7 @@ public class RequiredModelMBean
} }
/* Check attributeDescriptor for getMethod */ /* Check attributeDescriptor for getMethod */
ModelMBeanAttributeInfo attrInfo=null; Object response;
Descriptor attrDescr=null;
Object response = null;
try { try {
if (modelMBeanInfo == null) if (modelMBeanInfo == null)
...@@ -1435,14 +1433,14 @@ public class RequiredModelMBean ...@@ -1435,14 +1433,14 @@ public class RequiredModelMBean
"getAttribute failed: ModelMBeanInfo not found for "+ "getAttribute failed: ModelMBeanInfo not found for "+
attrName); attrName);
attrInfo = modelMBeanInfo.getAttribute(attrName); ModelMBeanAttributeInfo attrInfo = modelMBeanInfo.getAttribute(attrName);
Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor(); Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor();
if (attrInfo == null) if (attrInfo == null)
throw new AttributeNotFoundException("getAttribute failed:"+ throw new AttributeNotFoundException("getAttribute failed:"+
" ModelMBeanAttributeInfo not found for " + attrName); " ModelMBeanAttributeInfo not found for " + attrName);
attrDescr = attrInfo.getDescriptor(); Descriptor attrDescr = attrInfo.getDescriptor();
if (attrDescr != null) { if (attrDescr != null) {
if (!attrInfo.isReadable()) if (!attrInfo.isReadable())
throw new AttributeNotFoundException( throw new AttributeNotFoundException(
...@@ -1684,14 +1682,13 @@ public class RequiredModelMBean ...@@ -1684,14 +1682,13 @@ public class RequiredModelMBean
"getAttributes(String[])","Entry"); "getAttributes(String[])","Entry");
} }
AttributeList responseList = null;
if (attrNames == null) if (attrNames == null)
throw new RuntimeOperationsException(new throw new RuntimeOperationsException(new
IllegalArgumentException("attributeNames must not be null"), IllegalArgumentException("attributeNames must not be null"),
"Exception occurred trying to get attributes of a "+ "Exception occurred trying to get attributes of a "+
"RequiredModelMBean"); "RequiredModelMBean");
responseList = new AttributeList(); AttributeList responseList = new AttributeList();
for (int i = 0; i < attrNames.length; i++) { for (int i = 0; i < attrNames.length; i++) {
try { try {
responseList.add(new Attribute(attrNames[i], responseList.add(new Attribute(attrNames[i],
...@@ -1833,8 +1830,6 @@ public class RequiredModelMBean ...@@ -1833,8 +1830,6 @@ public class RequiredModelMBean
throw new AttributeNotFoundException("setAttribute failed: " throw new AttributeNotFoundException("setAttribute failed: "
+ attrName + " is not writable "); + attrName + " is not writable ");
Object setResponse = null;
String attrSetMethod = (String) String attrSetMethod = (String)
(attrDescr.getFieldValue("setMethod")); (attrDescr.getFieldValue("setMethod"));
String attrGetMethod = (String) String attrGetMethod = (String)
...@@ -1873,9 +1868,9 @@ public class RequiredModelMBean ...@@ -1873,9 +1868,9 @@ public class RequiredModelMBean
} }
updateDescriptor = true; updateDescriptor = true;
} else { } else {
setResponse = invoke(attrSetMethod, invoke(attrSetMethod,
(new Object[] {attrValue}), (new Object[] {attrValue}),
(new String[] {attrType}) ); (new String[] {attrType}) );
} }
/* change cached value */ /* change cached value */
...@@ -2023,8 +2018,6 @@ public class RequiredModelMBean ...@@ -2023,8 +2018,6 @@ public class RequiredModelMBean
private synchronized void writeToLog(String logFileName, private synchronized void writeToLog(String logFileName,
String logEntry) throws Exception { String logEntry) throws Exception {
PrintStream logOut = null;
FileOutputStream fos = null;
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), RequiredModelMBean.class.getName(),
...@@ -2041,9 +2034,9 @@ public class RequiredModelMBean ...@@ -2041,9 +2034,9 @@ public class RequiredModelMBean
return; return;
} }
FileOutputStream fos = new FileOutputStream(logFileName, true);
try { try {
fos = new FileOutputStream(logFileName, true); PrintStream logOut = new PrintStream(fos);
logOut = new PrintStream(fos);
logOut.println(logEntry); logOut.println(logEntry);
logOut.close(); logOut.close();
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
...@@ -2062,6 +2055,8 @@ public class RequiredModelMBean ...@@ -2062,6 +2055,8 @@ public class RequiredModelMBean
logFileName); logFileName);
} }
throw e; throw e;
} finally {
fos.close();
} }
} }
......
...@@ -740,16 +740,16 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { ...@@ -740,16 +740,16 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
// //
switch (o.getType()) { switch (o.getType()) {
case INTEGER: case INTEGER:
o.setThreshold(new Integer((int)threshold_value)); o.setThreshold(Integer.valueOf((int)threshold_value));
break; break;
case BYTE: case BYTE:
o.setThreshold(new Byte((byte)threshold_value)); o.setThreshold(Byte.valueOf((byte)threshold_value));
break; break;
case SHORT: case SHORT:
o.setThreshold(new Short((short)threshold_value)); o.setThreshold(Short.valueOf((short)threshold_value));
break; break;
case LONG: case LONG:
o.setThreshold(new Long(threshold_value)); o.setThreshold(Long.valueOf(threshold_value));
break; break;
default: default:
// Should never occur... // Should never occur...
...@@ -810,10 +810,10 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean { ...@@ -810,10 +810,10 @@ public class CounterMonitor extends Monitor implements CounterMonitorMBean {
derived += modulus.longValue(); derived += modulus.longValue();
switch (o.getType()) { switch (o.getType()) {
case INTEGER: o.setDerivedGauge(new Integer((int) derived)); break; case INTEGER: o.setDerivedGauge(Integer.valueOf((int) derived)); break;
case BYTE: o.setDerivedGauge(new Byte((byte) derived)); break; case BYTE: o.setDerivedGauge(Byte.valueOf((byte) derived)); break;
case SHORT: o.setDerivedGauge(new Short((short) derived)); break; case SHORT: o.setDerivedGauge(Short.valueOf((short) derived)); break;
case LONG: o.setDerivedGauge(new Long(derived)); break; case LONG: o.setDerivedGauge(Long.valueOf(derived)); break;
default: default:
// Should never occur... // Should never occur...
MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(), MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(),
......
...@@ -636,28 +636,28 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean { ...@@ -636,28 +636,28 @@ public class GaugeMonitor extends Monitor implements GaugeMonitorMBean {
Number der; Number der;
switch (o.getType()) { switch (o.getType()) {
case INTEGER: case INTEGER:
der = new Integer(((Integer)scanGauge).intValue() - der = Integer.valueOf(((Integer)scanGauge).intValue() -
((Integer)prev).intValue()); ((Integer)prev).intValue());
break; break;
case BYTE: case BYTE:
der = new Byte((byte)(((Byte)scanGauge).byteValue() - der = Byte.valueOf((byte)(((Byte)scanGauge).byteValue() -
((Byte)prev).byteValue())); ((Byte)prev).byteValue()));
break; break;
case SHORT: case SHORT:
der = new Short((short)(((Short)scanGauge).shortValue() - der = Short.valueOf((short)(((Short)scanGauge).shortValue() -
((Short)prev).shortValue())); ((Short)prev).shortValue()));
break; break;
case LONG: case LONG:
der = new Long(((Long)scanGauge).longValue() - der = Long.valueOf(((Long)scanGauge).longValue() -
((Long)prev).longValue()); ((Long)prev).longValue());
break; break;
case FLOAT: case FLOAT:
der = new Float(((Float)scanGauge).floatValue() - der = Float.valueOf(((Float)scanGauge).floatValue() -
((Float)prev).floatValue()); ((Float)prev).floatValue());
break; break;
case DOUBLE: case DOUBLE:
der = new Double(((Double)scanGauge).doubleValue() - der = Double.valueOf(((Double)scanGauge).doubleValue() -
((Double)prev).doubleValue()); ((Double)prev).doubleValue());
break; break;
default: default:
// Should never occur... // Should never occur...
......
...@@ -367,7 +367,7 @@ public abstract class Monitor ...@@ -367,7 +367,7 @@ public abstract class Monitor
/** /**
* Constant used to initialize all the numeric values. * Constant used to initialize all the numeric values.
*/ */
static final Integer INTEGER_ZERO = new Integer(0); static final Integer INTEGER_ZERO = 0;
/* /*
...@@ -1122,12 +1122,12 @@ public abstract class Monitor ...@@ -1122,12 +1122,12 @@ public abstract class Monitor
*/ */
private void monitor(ObservedObject o, int index, int an[]) { private void monitor(ObservedObject o, int index, int an[]) {
String attribute = null; String attribute;
String notifType = null; String notifType = null;
String msg = null; String msg = null;
Object derGauge = null; Object derGauge = null;
Object trigger = null; Object trigger = null;
ObjectName object = null; ObjectName object;
Comparable<?> value = null; Comparable<?> value = null;
MonitorNotification alarm = null; MonitorNotification alarm = null;
...@@ -1565,7 +1565,7 @@ public abstract class Monitor ...@@ -1565,7 +1565,7 @@ public abstract class Monitor
final ThreadGroup group; final ThreadGroup group;
final AtomicInteger threadNumber = new AtomicInteger(1); final AtomicInteger threadNumber = new AtomicInteger(1);
final String namePrefix; final String namePrefix;
final String nameSuffix = "]"; static final String nameSuffix = "]";
public DaemonThreadFactory(String poolName) { public DaemonThreadFactory(String poolName) {
SecurityManager s = System.getSecurityManager(); SecurityManager s = System.getSecurityManager();
......
...@@ -726,7 +726,7 @@ public class ArrayType<T> extends OpenType<T> { ...@@ -726,7 +726,7 @@ public class ArrayType<T> extends OpenType<T> {
value += dimension; value += dimension;
value += elementType.hashCode(); value += elementType.hashCode();
value += Boolean.valueOf(primitiveArray).hashCode(); value += Boolean.valueOf(primitiveArray).hashCode();
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -426,7 +426,7 @@ public class CompositeType extends OpenType<CompositeData> { ...@@ -426,7 +426,7 @@ public class CompositeType extends OpenType<CompositeData> {
value += key.hashCode(); value += key.hashCode();
value += this.nameToType.get(key).hashCode(); value += this.nameToType.get(key).hashCode();
} }
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -769,7 +769,6 @@ public class OpenMBeanAttributeInfoSupport ...@@ -769,7 +769,6 @@ public class OpenMBeanAttributeInfoSupport
"array with same dimensions"; "array with same dimensions";
throw new IllegalArgumentException(msg); throw new IllegalArgumentException(msg);
} }
Class<?> targetComponentClass = targetArrayClass.getComponentType();
OpenType<?> componentOpenType; OpenType<?> componentOpenType;
if (dim == 1) if (dim == 1)
componentOpenType = baseType; componentOpenType = baseType;
......
...@@ -252,7 +252,7 @@ public class OpenMBeanConstructorInfoSupport ...@@ -252,7 +252,7 @@ public class OpenMBeanConstructorInfoSupport
int value = 0; int value = 0;
value += this.getName().hashCode(); value += this.getName().hashCode();
value += Arrays.asList(this.getSignature()).hashCode(); value += Arrays.asList(this.getSignature()).hashCode();
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -347,7 +347,7 @@ public class OpenMBeanInfoSupport ...@@ -347,7 +347,7 @@ public class OpenMBeanInfoSupport
value += arraySetHash(this.getConstructors()); value += arraySetHash(this.getConstructors());
value += arraySetHash(this.getOperations()); value += arraySetHash(this.getOperations());
value += arraySetHash(this.getNotifications()); value += arraySetHash(this.getNotifications());
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -352,7 +352,7 @@ public class OpenMBeanOperationInfoSupport ...@@ -352,7 +352,7 @@ public class OpenMBeanOperationInfoSupport
value += Arrays.asList(this.getSignature()).hashCode(); value += Arrays.asList(this.getSignature()).hashCode();
value += this.getReturnOpenType().hashCode(); value += this.getReturnOpenType().hashCode();
value += this.getImpact(); value += this.getImpact();
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -257,7 +257,7 @@ public final class SimpleType<T> extends OpenType<T> { ...@@ -257,7 +257,7 @@ public final class SimpleType<T> extends OpenType<T> {
// Calculate the hash code value if it has not yet been done (ie 1st call to hashCode()) // Calculate the hash code value if it has not yet been done (ie 1st call to hashCode())
// //
if (myHashCode == null) { if (myHashCode == null) {
myHashCode = new Integer(this.getClassName().hashCode()); myHashCode = Integer.valueOf(this.getClassName().hashCode());
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -332,7 +332,7 @@ public class TabularType extends OpenType<TabularData> { ...@@ -332,7 +332,7 @@ public class TabularType extends OpenType<TabularData> {
for (Iterator k = indexNames.iterator(); k.hasNext(); ) { for (Iterator k = indexNames.iterator(); k.hasNext(); ) {
value += k.next().hashCode(); value += k.next().hashCode();
} }
myHashCode = new Integer(value); myHashCode = Integer.valueOf(value);
} }
// return always the same hash code for this instance (immutable) // return always the same hash code for this instance (immutable)
......
...@@ -369,7 +369,7 @@ public class RelationNotification extends Notification { ...@@ -369,7 +369,7 @@ public class RelationNotification extends Notification {
* @return a {@link List} of {@link ObjectName}. * @return a {@link List} of {@link ObjectName}.
*/ */
public List<ObjectName> getMBeansToUnregister() { public List<ObjectName> getMBeansToUnregister() {
List<ObjectName> result = null; List<ObjectName> result;
if (unregisterMBeanList != null) { if (unregisterMBeanList != null) {
result = new ArrayList<ObjectName>(unregisterMBeanList); result = new ArrayList<ObjectName>(unregisterMBeanList);
} else { } else {
...@@ -397,7 +397,7 @@ public class RelationNotification extends Notification { ...@@ -397,7 +397,7 @@ public class RelationNotification extends Notification {
* @return the old value of the updated role. * @return the old value of the updated role.
*/ */
public List<ObjectName> getOldRoleValue() { public List<ObjectName> getOldRoleValue() {
List<ObjectName> result = null; List<ObjectName> result;
if (oldRoleValue != null) { if (oldRoleValue != null) {
result = new ArrayList<ObjectName>(oldRoleValue); result = new ArrayList<ObjectName>(oldRoleValue);
} else { } else {
...@@ -412,7 +412,7 @@ public class RelationNotification extends Notification { ...@@ -412,7 +412,7 @@ public class RelationNotification extends Notification {
* @return the new value of the updated role. * @return the new value of the updated role.
*/ */
public List<ObjectName> getNewRoleValue() { public List<ObjectName> getNewRoleValue() {
List<ObjectName> result = null; List<ObjectName> result;
if (newRoleValue != null) { if (newRoleValue != null) {
result = new ArrayList<ObjectName>(newRoleValue); result = new ArrayList<ObjectName>(newRoleValue);
} else { } else {
......
...@@ -35,6 +35,7 @@ import java.util.Iterator; ...@@ -35,6 +35,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level; import java.util.logging.Level;
import javax.management.Attribute; import javax.management.Attribute;
...@@ -122,7 +123,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -122,7 +123,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Internal counter to provide sequence numbers for notifications sent by: // Internal counter to provide sequence numbers for notifications sent by:
// - the Relation Service // - the Relation Service
// - a relation handled by the Relation Service // - a relation handled by the Relation Service
private Long myNtfSeqNbrCounter = new Long(0); private final AtomicLong atomicSeqNo = new AtomicLong();
// ObjectName used to register the Relation Service in the MBean Server // ObjectName used to register the Relation Service in the MBean Server
private ObjectName myObjName = null; private ObjectName myObjName = null;
...@@ -256,19 +257,6 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -256,19 +257,6 @@ public class RelationService extends NotificationBroadcasterSupport
return; return;
} }
// Returns internal counter to be used for Sequence Numbers of
// notifications to be raised by:
// - a relation handled by this Relation Service (when updated)
// - the Relation Service
private Long getNotificationSequenceNumber() {
Long result = null;
synchronized(myNtfSeqNbrCounter) {
result = new Long(myNtfSeqNbrCounter.longValue() + 1);
myNtfSeqNbrCounter = new Long(result.longValue());
}
return result;
}
// //
// Relation type handling // Relation type handling
// //
...@@ -369,7 +357,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -369,7 +357,7 @@ public class RelationService extends NotificationBroadcasterSupport
* @return ArrayList of relation type names (Strings) * @return ArrayList of relation type names (Strings)
*/ */
public List<String> getAllRelationTypeNames() { public List<String> getAllRelationTypeNames() {
ArrayList<String> result = null; ArrayList<String> result;
synchronized(myRelType2ObjMap) { synchronized(myRelType2ObjMap) {
result = new ArrayList<String>(myRelType2ObjMap.keySet()); result = new ArrayList<String>(myRelType2ObjMap.keySet());
} }
...@@ -684,7 +672,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -684,7 +672,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw InstanceNotFoundException (but detected above) // Can throw InstanceNotFoundException (but detected above)
// No MBeanException as no exception raised by this method, and no // No MBeanException as no exception raised by this method, and no
// ReflectionException // ReflectionException
String relId = null; String relId;
try { try {
relId = (String)(myMBeanServer.getAttribute(relationObjectName, relId = (String)(myMBeanServer.getAttribute(relationObjectName,
"RelationId")); "RelationId"));
...@@ -707,7 +695,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -707,7 +695,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw InstanceNotFoundException (but detected above) // Can throw InstanceNotFoundException (but detected above)
// No MBeanException as no exception raised by this method, no // No MBeanException as no exception raised by this method, no
// ReflectionException // ReflectionException
ObjectName relServObjName = null; ObjectName relServObjName;
try { try {
relServObjName = (ObjectName) relServObjName = (ObjectName)
(myMBeanServer.getAttribute(relationObjectName, (myMBeanServer.getAttribute(relationObjectName,
...@@ -737,7 +725,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -737,7 +725,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw InstanceNotFoundException (but detected above) // Can throw InstanceNotFoundException (but detected above)
// No MBeanException as no exception raised by this method, no // No MBeanException as no exception raised by this method, no
// ReflectionException // ReflectionException
String relTypeName = null; String relTypeName;
try { try {
relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName, relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName,
"RelationTypeName")); "RelationTypeName"));
...@@ -758,7 +746,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -758,7 +746,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw InstanceNotFoundException (but detected above) // Can throw InstanceNotFoundException (but detected above)
// No MBeanException as no exception raised by this method, no // No MBeanException as no exception raised by this method, no
// ReflectionException // ReflectionException
RoleList roleList = null; RoleList roleList;
try { try {
roleList = (RoleList)(myMBeanServer.invoke(relationObjectName, roleList = (RoleList)(myMBeanServer.invoke(relationObjectName,
"retrieveAllRoles", "retrieveAllRoles",
...@@ -912,7 +900,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -912,7 +900,7 @@ public class RelationService extends NotificationBroadcasterSupport
* @return ArrayList of String * @return ArrayList of String
*/ */
public List<String> getAllRelationIds() { public List<String> getAllRelationIds() {
List<String> result = null; List<String> result;
synchronized(myRelId2ObjMap) { synchronized(myRelId2ObjMap) {
result = new ArrayList<String>(myRelId2ObjMap.keySet()); result = new ArrayList<String>(myRelId2ObjMap.keySet());
} }
...@@ -948,7 +936,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -948,7 +936,7 @@ public class RelationService extends NotificationBroadcasterSupport
RELATION_LOGGER.entering(RelationService.class.getName(), RELATION_LOGGER.entering(RelationService.class.getName(),
"checkRoleReading", new Object[] {roleName, relationTypeName}); "checkRoleReading", new Object[] {roleName, relationTypeName});
Integer result = null; Integer result;
// Can throw a RelationTypeNotFoundException // Can throw a RelationTypeNotFoundException
RelationType relType = getRelationType(relationTypeName); RelationType relType = getRelationType(relationTypeName);
...@@ -965,7 +953,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -965,7 +953,7 @@ public class RelationService extends NotificationBroadcasterSupport
false); false);
} catch (RoleInfoNotFoundException exc) { } catch (RoleInfoNotFoundException exc) {
result = new Integer(RoleStatus.NO_ROLE_WITH_NAME); result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
} }
RELATION_LOGGER.exiting(RelationService.class.getName(), RELATION_LOGGER.exiting(RelationService.class.getName(),
...@@ -1021,13 +1009,13 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -1021,13 +1009,13 @@ public class RelationService extends NotificationBroadcasterSupport
writeChkFlag = false; writeChkFlag = false;
} }
RoleInfo roleInfo = null; RoleInfo roleInfo;
try { try {
roleInfo = relType.getRoleInfo(roleName); roleInfo = relType.getRoleInfo(roleName);
} catch (RoleInfoNotFoundException exc) { } catch (RoleInfoNotFoundException exc) {
RELATION_LOGGER.exiting(RelationService.class.getName(), RELATION_LOGGER.exiting(RelationService.class.getName(),
"checkRoleWriting"); "checkRoleWriting");
return new Integer(RoleStatus.NO_ROLE_WITH_NAME); return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
} }
Integer result = checkRoleInt(2, Integer result = checkRoleInt(2,
...@@ -1436,7 +1424,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -1436,7 +1424,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Relation id to relation type name map // Relation id to relation type name map
// First retrieves the relation type name // First retrieves the relation type name
String relTypeName = null; String relTypeName;
synchronized(myRelId2RelTypeMap) { synchronized(myRelId2RelTypeMap) {
relTypeName = myRelId2RelTypeMap.get(relationId); relTypeName = myRelId2RelTypeMap.get(relationId);
myRelId2RelTypeMap.remove(relationId); myRelId2RelTypeMap.remove(relationId);
...@@ -1641,7 +1629,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -1641,7 +1629,7 @@ public class RelationService extends NotificationBroadcasterSupport
// List of relation ids of interest regarding the selected // List of relation ids of interest regarding the selected
// relation type // relation type
List<String> relIdList = null; List<String> relIdList;
if (relationTypeName == null) { if (relationTypeName == null) {
// Considers all relations // Considers all relations
relIdList = new ArrayList<String>(allRelIdSet); relIdList = new ArrayList<String>(allRelIdSet);
...@@ -1655,7 +1643,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -1655,7 +1643,7 @@ public class RelationService extends NotificationBroadcasterSupport
for (String currRelId : allRelIdSet) { for (String currRelId : allRelIdSet) {
// Retrieves its relation type // Retrieves its relation type
String currRelTypeName = null; String currRelTypeName;
synchronized(myRelId2RelTypeMap) { synchronized(myRelId2RelTypeMap) {
currRelTypeName = currRelTypeName =
myRelId2RelTypeMap.get(currRelId); myRelId2RelTypeMap.get(currRelId);
...@@ -1952,7 +1940,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -1952,7 +1940,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw a RelationNotFoundException // Can throw a RelationNotFoundException
Object relObj = getRelation(relationId); Object relObj = getRelation(relationId);
RoleResult result = null; RoleResult result;
if (relObj instanceof RelationSupport) { if (relObj instanceof RelationSupport) {
// Internal relation // Internal relation
...@@ -2022,7 +2010,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2022,7 +2010,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw a RelationNotFoundException // Can throw a RelationNotFoundException
Object relObj = getRelation(relationId); Object relObj = getRelation(relationId);
RoleResult result = null; RoleResult result;
if (relObj instanceof RelationSupport) { if (relObj instanceof RelationSupport) {
// Internal relation // Internal relation
...@@ -2073,7 +2061,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2073,7 +2061,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw a RelationNotFoundException // Can throw a RelationNotFoundException
Object relObj = getRelation(relationId); Object relObj = getRelation(relationId);
Integer result = null; Integer result;
if (relObj instanceof RelationSupport) { if (relObj instanceof RelationSupport) {
// Internal relation // Internal relation
...@@ -2268,7 +2256,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2268,7 +2256,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw a RelationNotFoundException // Can throw a RelationNotFoundException
Object relObj = getRelation(relationId); Object relObj = getRelation(relationId);
RoleResult result = null; RoleResult result;
if (relObj instanceof RelationSupport) { if (relObj instanceof RelationSupport) {
// Internal relation // Internal relation
...@@ -2390,7 +2378,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2390,7 +2378,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Can throw a RelationNotFoundException // Can throw a RelationNotFoundException
Object relObj = getRelation(relationId); Object relObj = getRelation(relationId);
String result = null; String result;
if (relObj instanceof RelationSupport) { if (relObj instanceof RelationSupport) {
// Internal relation // Internal relation
...@@ -2473,7 +2461,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2473,7 +2461,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Note: do both tests as a relation can be an MBean and be // Note: do both tests as a relation can be an MBean and be
// itself referenced in another relation :) // itself referenced in another relation :)
String relId = null; String relId;
synchronized(myRelMBeanObjName2RelIdMap){ synchronized(myRelMBeanObjName2RelIdMap){
relId = myRelMBeanObjName2RelIdMap.get(mbeanName); relId = myRelMBeanObjName2RelIdMap.get(mbeanName);
} }
...@@ -2511,9 +2499,6 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2511,9 +2499,6 @@ public class RelationService extends NotificationBroadcasterSupport
RELATION_LOGGER.entering(RelationService.class.getName(), RELATION_LOGGER.entering(RelationService.class.getName(),
"getNotificationInfo"); "getNotificationInfo");
MBeanNotificationInfo[] ntfInfoArray =
new MBeanNotificationInfo[1];
String ntfClass = "javax.management.relation.RelationNotification"; String ntfClass = "javax.management.relation.RelationNotification";
String[] ntfTypes = new String[] { String[] ntfTypes = new String[] {
...@@ -2615,7 +2600,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2615,7 +2600,7 @@ public class RelationService extends NotificationBroadcasterSupport
"getRelationType", relationTypeName); "getRelationType", relationTypeName);
// No null relation type accepted, so can use get() // No null relation type accepted, so can use get()
RelationType relType = null; RelationType relType;
synchronized(myRelType2ObjMap) { synchronized(myRelType2ObjMap) {
relType = (myRelType2ObjMap.get(relationTypeName)); relType = (myRelType2ObjMap.get(relationTypeName));
} }
...@@ -2659,7 +2644,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -2659,7 +2644,7 @@ public class RelationService extends NotificationBroadcasterSupport
"getRelation", relationId); "getRelation", relationId);
// No null relation accepted, so can use get() // No null relation accepted, so can use get()
Object rel = null; Object rel;
synchronized(myRelId2ObjMap) { synchronized(myRelId2ObjMap) {
rel = myRelId2ObjMap.get(relationId); rel = myRelId2ObjMap.get(relationId);
} }
...@@ -3077,7 +3062,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3077,7 +3062,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Retrieves corresponding role info // Retrieves corresponding role info
// Can throw a RoleInfoNotFoundException to be converted into a // Can throw a RoleInfoNotFoundException to be converted into a
// RoleNotFoundException // RoleNotFoundException
RoleInfo roleInfo = null; RoleInfo roleInfo;
try { try {
roleInfo = relType.getRoleInfo(currRoleName); roleInfo = relType.getRoleInfo(currRoleName);
} catch (RoleInfoNotFoundException exc) { } catch (RoleInfoNotFoundException exc) {
...@@ -3227,7 +3212,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3227,7 +3212,7 @@ public class RelationService extends NotificationBroadcasterSupport
if (!(roleName.equals(expName))) { if (!(roleName.equals(expName))) {
RELATION_LOGGER.exiting(RelationService.class.getName(), RELATION_LOGGER.exiting(RelationService.class.getName(),
"checkRoleInt"); "checkRoleInt");
return new Integer(RoleStatus.NO_ROLE_WITH_NAME); return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
} }
// Checks read access if required // Checks read access if required
...@@ -3236,7 +3221,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3236,7 +3221,7 @@ public class RelationService extends NotificationBroadcasterSupport
if (!isReadable) { if (!isReadable) {
RELATION_LOGGER.exiting(RelationService.class.getName(), RELATION_LOGGER.exiting(RelationService.class.getName(),
"checkRoleInt"); "checkRoleInt");
return new Integer(RoleStatus.ROLE_NOT_READABLE); return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
} else { } else {
// End of check :) // End of check :)
RELATION_LOGGER.exiting(RelationService.class.getName(), RELATION_LOGGER.exiting(RelationService.class.getName(),
...@@ -3572,7 +3557,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3572,7 +3557,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Relation type name // Relation type name
// Note: do not use getRelationTypeName() as if it is a relation MBean // Note: do not use getRelationTypeName() as if it is a relation MBean
// it is already unregistered. // it is already unregistered.
String relTypeName = null; String relTypeName;
synchronized(myRelId2RelTypeMap) { synchronized(myRelId2RelTypeMap) {
relTypeName = (myRelId2RelTypeMap.get(relationId)); relTypeName = (myRelId2RelTypeMap.get(relationId));
} }
...@@ -3609,7 +3594,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3609,7 +3594,7 @@ public class RelationService extends NotificationBroadcasterSupport
} }
// Sequence number // Sequence number
Long seqNbr = getNotificationSequenceNumber(); Long seqNo = atomicSeqNo.incrementAndGet();
// Timestamp // Timestamp
Date currDate = new Date(); Date currDate = new Date();
...@@ -3625,7 +3610,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3625,7 +3610,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Creation or removal // Creation or removal
ntf = new RelationNotification(ntfType, ntf = new RelationNotification(ntfType,
this, this,
seqNbr.longValue(), seqNo.longValue(),
timeStamp, timeStamp,
message, message,
relationId, relationId,
...@@ -3640,7 +3625,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3640,7 +3625,7 @@ public class RelationService extends NotificationBroadcasterSupport
// Update // Update
ntf = new RelationNotification(ntfType, ntf = new RelationNotification(ntfType,
this, this,
seqNbr.longValue(), seqNo.longValue(),
timeStamp, timeStamp,
message, message,
relationId, relationId,
...@@ -3732,7 +3717,7 @@ public class RelationService extends NotificationBroadcasterSupport ...@@ -3732,7 +3717,7 @@ public class RelationService extends NotificationBroadcasterSupport
// //
// Shall not throw RelationTypeNotFoundException or // Shall not throw RelationTypeNotFoundException or
// RoleInfoNotFoundException // RoleInfoNotFoundException
RoleInfo currRoleInfo = null; RoleInfo currRoleInfo;
try { try {
currRoleInfo = getRoleInfo(currRelTypeName, currRoleInfo = getRoleInfo(currRelTypeName,
currRoleName); currRoleName);
......
...@@ -34,6 +34,7 @@ import java.util.Iterator; ...@@ -34,6 +34,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER; import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER;
import static com.sun.jmx.mbeanserver.Util.cast; import static com.sun.jmx.mbeanserver.Util.cast;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
...@@ -110,7 +111,7 @@ public class RelationSupport ...@@ -110,7 +111,7 @@ public class RelationSupport
private Map<String,Role> myRoleName2ValueMap = new HashMap<String,Role>(); private Map<String,Role> myRoleName2ValueMap = new HashMap<String,Role>();
// Flag to indicate if the object has been added in the Relation Service // Flag to indicate if the object has been added in the Relation Service
private Boolean myInRelServFlg = null; private final AtomicBoolean myInRelServFlg = new AtomicBoolean();
// //
// Constructors // Constructors
...@@ -403,7 +404,7 @@ public class RelationSupport ...@@ -403,7 +404,7 @@ public class RelationSupport
"getRoleCardinality", roleName); "getRoleCardinality", roleName);
// Try to retrieve the role // Try to retrieve the role
Role role = null; Role role;
synchronized(myRoleName2ValueMap) { synchronized(myRoleName2ValueMap) {
// No null Role is allowed, so direct use of get() // No null Role is allowed, so direct use of get()
role = (myRoleName2ValueMap.get(roleName)); role = (myRoleName2ValueMap.get(roleName));
...@@ -427,7 +428,7 @@ public class RelationSupport ...@@ -427,7 +428,7 @@ public class RelationSupport
RELATION_LOGGER.exiting(RelationSupport.class.getName(), RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"getRoleCardinality"); "getRoleCardinality");
return new Integer(roleValue.size()); return roleValue.size();
} }
/** /**
...@@ -701,11 +702,7 @@ public class RelationSupport ...@@ -701,11 +702,7 @@ public class RelationSupport
* the Relation Service. * the Relation Service.
*/ */
public Boolean isInRelationService() { public Boolean isInRelationService() {
Boolean result = null; return myInRelServFlg.get();
synchronized(myInRelServFlg) {
result = Boolean.valueOf(myInRelServFlg.booleanValue());
}
return result;
} }
public void setRelationServiceManagementFlag(Boolean flag) public void setRelationServiceManagementFlag(Boolean flag)
...@@ -715,10 +712,7 @@ public class RelationSupport ...@@ -715,10 +712,7 @@ public class RelationSupport
String excMsg = "Invalid parameter."; String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg); throw new IllegalArgumentException(excMsg);
} }
synchronized(myInRelServFlg) { myInRelServFlg.set(flag);
myInRelServFlg = Boolean.valueOf(flag.booleanValue());
}
return;
} }
// //
...@@ -790,7 +784,7 @@ public class RelationSupport ...@@ -790,7 +784,7 @@ public class RelationSupport
int pbType = 0; int pbType = 0;
Role role = null; Role role;
synchronized(myRoleName2ValueMap) { synchronized(myRoleName2ValueMap) {
// No null Role is allowed, so direct use of get() // No null Role is allowed, so direct use of get()
role = (myRoleName2ValueMap.get(roleName)); role = (myRoleName2ValueMap.get(roleName));
...@@ -801,7 +795,7 @@ public class RelationSupport ...@@ -801,7 +795,7 @@ public class RelationSupport
} else { } else {
// Checks if the role is readable // Checks if the role is readable
Integer status = null; Integer status;
if (relationServCallFlg) { if (relationServCallFlg) {
...@@ -851,7 +845,7 @@ public class RelationSupport ...@@ -851,7 +845,7 @@ public class RelationSupport
pbType = status.intValue(); pbType = status.intValue();
} }
Object result = null; Object result;
if (pbType == 0) { if (pbType == 0) {
// Role can be retrieved // Role can be retrieved
...@@ -937,7 +931,7 @@ public class RelationSupport ...@@ -937,7 +931,7 @@ public class RelationSupport
for (int i = 0; i < roleNameArray.length; i++) { for (int i = 0; i < roleNameArray.length; i++) {
String currRoleName = roleNameArray[i]; String currRoleName = roleNameArray[i];
Object currResult = null; Object currResult;
// Can throw RelationServiceNotRegisteredException // Can throw RelationServiceNotRegisteredException
// //
...@@ -1102,13 +1096,13 @@ public class RelationSupport ...@@ -1102,13 +1096,13 @@ public class RelationSupport
// handle initialization of role when creating the relation // handle initialization of role when creating the relation
// (roles provided in the RoleList parameter are directly set but // (roles provided in the RoleList parameter are directly set but
// roles automatically initialized are set using setRole()) // roles automatically initialized are set using setRole())
Role role = null; Role role;
synchronized(myRoleName2ValueMap) { synchronized(myRoleName2ValueMap) {
role = (myRoleName2ValueMap.get(roleName)); role = (myRoleName2ValueMap.get(roleName));
} }
List<ObjectName> oldRoleValue; List<ObjectName> oldRoleValue;
Boolean initFlg = null; Boolean initFlg;
if (role == null) { if (role == null) {
initFlg = true; initFlg = true;
...@@ -1122,7 +1116,7 @@ public class RelationSupport ...@@ -1122,7 +1116,7 @@ public class RelationSupport
// Checks if the role can be set: is writable (except if // Checks if the role can be set: is writable (except if
// initialization) and correct value // initialization) and correct value
try { try {
Integer status = null; Integer status;
if (relationServCallFlg) { if (relationServCallFlg) {
...@@ -1314,7 +1308,7 @@ public class RelationSupport ...@@ -1314,7 +1308,7 @@ public class RelationSupport
Object[] params = new Object[3]; Object[] params = new Object[3];
params[0] = myRelId; params[0] = myRelId;
params[1] = newRole; params[1] = newRole;
params[2] = ((ArrayList)oldRoleValue); params[2] = oldRoleValue;
String[] signature = new String[3]; String[] signature = new String[3];
signature[0] = "java.lang.String"; signature[0] = "java.lang.String";
signature[1] = "javax.management.relation.Role"; signature[1] = "javax.management.relation.Role";
...@@ -1598,7 +1592,6 @@ public class RelationSupport ...@@ -1598,7 +1592,6 @@ public class RelationSupport
myRelTypeName = relationTypeName; myRelTypeName = relationTypeName;
// Can throw InvalidRoleValueException // Can throw InvalidRoleValueException
initRoleMap(list); initRoleMap(list);
myInRelServFlg = Boolean.FALSE;
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers"); RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers");
return; return;
...@@ -1710,7 +1703,7 @@ public class RelationSupport ...@@ -1710,7 +1703,7 @@ public class RelationSupport
roleName, relationServCallFlg, relationServ}); roleName, relationServCallFlg, relationServ});
// Retrieves current role value // Retrieves current role value
Role role = null; Role role;
synchronized(myRoleName2ValueMap) { synchronized(myRoleName2ValueMap) {
role = (myRoleName2ValueMap.get(roleName)); role = (myRoleName2ValueMap.get(roleName));
} }
......
...@@ -435,7 +435,7 @@ public class JMXConnectorFactory { ...@@ -435,7 +435,7 @@ public class JMXConnectorFactory {
Iterator<JMXConnectorProvider> providers = Iterator<JMXConnectorProvider> providers =
getProviderIterator(JMXConnectorProvider.class, loader); getProviderIterator(JMXConnectorProvider.class, loader);
JMXConnector connection = null; JMXConnector connection;
IOException exception = null; IOException exception = null;
while(providers.hasNext()) { while(providers.hasNext()) {
try { try {
...@@ -450,7 +450,7 @@ public class JMXConnectorFactory { ...@@ -450,7 +450,7 @@ public class JMXConnectorFactory {
"] Service provider exception: " + e); "] Service provider exception: " + e);
if (!(e instanceof MalformedURLException)) { if (!(e instanceof MalformedURLException)) {
if (exception == null) { if (exception == null) {
if (exception instanceof IOException) { if (e instanceof IOException) {
exception = (IOException) e; exception = (IOException) e;
} else { } else {
exception = EnvHelp.initCause( exception = EnvHelp.initCause(
......
...@@ -215,12 +215,10 @@ public class JMXConnectorServerFactory { ...@@ -215,12 +215,10 @@ public class JMXConnectorServerFactory {
JMXConnectorFactory. JMXConnectorFactory.
getProviderIterator(JMXConnectorServerProvider.class, loader); getProviderIterator(JMXConnectorServerProvider.class, loader);
JMXConnectorServer connection = null;
IOException exception = null; IOException exception = null;
while (providers.hasNext()) { while (providers.hasNext()) {
try { try {
connection = providers.next().newJMXConnectorServer(url, map, mbs); return providers.next().newJMXConnectorServer(url, map, mbs);
return connection;
} catch (JMXProviderException e) { } catch (JMXProviderException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
...@@ -230,7 +228,7 @@ public class JMXConnectorServerFactory { ...@@ -230,7 +228,7 @@ public class JMXConnectorServerFactory {
"] Service provider exception: " + e); "] Service provider exception: " + e);
if (!(e instanceof MalformedURLException)) { if (!(e instanceof MalformedURLException)) {
if (exception == null) { if (exception == null) {
if (exception instanceof IOException) { if (e instanceof IOException) {
exception = (IOException) e; exception = (IOException) e;
} else { } else {
exception = EnvHelp.initCause( exception = EnvHelp.initCause(
......
...@@ -162,8 +162,6 @@ public class JMXServiceURL implements Serializable { ...@@ -162,8 +162,6 @@ public class JMXServiceURL implements Serializable {
requiredPrefix); requiredPrefix);
} }
int[] ptr = new int[1];
// Parse the protocol name // Parse the protocol name
final int protoStart = requiredPrefixLength; final int protoStart = requiredPrefixLength;
final int protoEnd = indexOf(serviceURL, ':', protoStart); final int protoEnd = indexOf(serviceURL, ':', protoStart);
...@@ -664,11 +662,6 @@ public class JMXServiceURL implements Serializable { ...@@ -664,11 +662,6 @@ public class JMXServiceURL implements Serializable {
hostNameBitSet.set('.'); hostNameBitSet.set('.');
} }
private static void addCharsToBitSet(BitSet set, String chars) {
for (int i = 0; i < chars.length(); i++)
set.set(chars.charAt(i));
}
/** /**
* The value returned by {@link #getProtocol()}. * The value returned by {@link #getProtocol()}.
*/ */
......
...@@ -1376,12 +1376,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ...@@ -1376,12 +1376,12 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
protected Integer addListenerForMBeanRemovedNotif() protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException { throws IOException, InstanceNotFoundException {
MarshalledObject<NotificationFilter> sFilter = null;
NotificationFilterSupport clientFilter = NotificationFilterSupport clientFilter =
new NotificationFilterSupport(); new NotificationFilterSupport();
clientFilter.enableType( clientFilter.enableType(
MBeanServerNotification.UNREGISTRATION_NOTIFICATION); MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
sFilter = new MarshalledObject<NotificationFilter>(clientFilter); MarshalledObject<NotificationFilter> sFilter =
new MarshalledObject<NotificationFilter>(clientFilter);
Integer[] listenerIDs; Integer[] listenerIDs;
final ObjectName[] names = final ObjectName[] names =
...@@ -1434,7 +1434,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ...@@ -1434,7 +1434,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
connectionId, connectionId,
clientNotifCounter++, clientNotifCounter++,
message, message,
new Long(number)); Long.valueOf(number));
sendNotification(n); sendNotification(n);
} }
} }
...@@ -1593,7 +1593,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ...@@ -1593,7 +1593,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
protected void doStart() throws IOException { protected void doStart() throws IOException {
// Get RMIServer stub from directory or URL encoding if needed. // Get RMIServer stub from directory or URL encoding if needed.
RMIServer stub = null; RMIServer stub;
try { try {
stub = (rmiServer!=null)?rmiServer: stub = (rmiServer!=null)?rmiServer:
findRMIServer(jmxServiceURL, env); findRMIServer(jmxServiceURL, env);
...@@ -2532,7 +2532,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable ...@@ -2532,7 +2532,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
* A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
* connect unconnected stubs. * connect unconnected stubs.
**/ **/
private static WeakReference<ORB> orb = null; private static volatile WeakReference<ORB> orb = null;
// TRACES & DEBUG // TRACES & DEBUG
//--------------- //---------------
......
...@@ -365,7 +365,7 @@ public class RMIConnectorServer extends JMXConnectorServer { ...@@ -365,7 +365,7 @@ public class RMIConnectorServer extends JMXConnectorServer {
// Access file property specified, create an instance // Access file property specified, create an instance
// of the MBeanServerFileAccessController class // of the MBeanServerFileAccessController class
// //
MBeanServerForwarder mbsf = null; MBeanServerForwarder mbsf;
try { try {
mbsf = new MBeanServerFileAccessController(accessFile); mbsf = new MBeanServerFileAccessController(accessFile);
} catch (IOException e) { } catch (IOException e) {
......
...@@ -344,13 +344,11 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -344,13 +344,11 @@ public class Timer extends NotificationBroadcasterSupport
// //
if (isActive == true) { if (isActive == true) {
TimerAlarmClock alarmClock;
for (Object[] obj : timerTable.values()) { for (Object[] obj : timerTable.values()) {
// Stop all the TimerAlarmClock. // Stop all the TimerAlarmClock.
// //
alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX]; TimerAlarmClock alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX];
if (alarmClock != null) { if (alarmClock != null) {
// alarmClock.interrupt(); // alarmClock.interrupt();
// try { // try {
...@@ -364,7 +362,6 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -364,7 +362,6 @@ public class Timer extends NotificationBroadcasterSupport
// // // //
alarmClock.cancel(); alarmClock.cancel();
alarmClock = null;
} }
} }
...@@ -458,8 +455,7 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -458,8 +455,7 @@ public class Timer extends NotificationBroadcasterSupport
// Create and add the timer notification into the timer table. // Create and add the timer notification into the timer table.
// //
Integer notifID = null; Integer notifID = Integer.valueOf(++counterID);
notifID = new Integer(++counterID);
// The sequenceNumber and the timeStamp attributes are updated // The sequenceNumber and the timeStamp attributes are updated
// when the notification is emitted by the timer. // when the notification is emitted by the timer.
...@@ -486,8 +482,8 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -486,8 +482,8 @@ public class Timer extends NotificationBroadcasterSupport
obj[TIMER_NOTIF_INDEX] = (Object)notif; obj[TIMER_NOTIF_INDEX] = (Object)notif;
obj[TIMER_DATE_INDEX] = (Object)d; obj[TIMER_DATE_INDEX] = (Object)d;
obj[TIMER_PERIOD_INDEX] = (Object) new Long(period); obj[TIMER_PERIOD_INDEX] = (Object) period;
obj[TIMER_NB_OCCUR_INDEX] = (Object) new Long(nbOccurences); obj[TIMER_NB_OCCUR_INDEX] = (Object) nbOccurences;
obj[ALARM_CLOCK_INDEX] = (Object)alarmClock; obj[ALARM_CLOCK_INDEX] = (Object)alarmClock;
obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate); obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate);
...@@ -678,7 +674,6 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -678,7 +674,6 @@ public class Timer extends NotificationBroadcasterSupport
// // Remove the reference on the TimerAlarmClock. // // Remove the reference on the TimerAlarmClock.
// // // //
alarmClock.cancel(); alarmClock.cancel();
alarmClock = null;
} }
// Remove the timer notification from the timer table. // Remove the timer notification from the timer table.
...@@ -755,7 +750,6 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -755,7 +750,6 @@ public class Timer extends NotificationBroadcasterSupport
// //
// } // }
alarmClock.cancel(); alarmClock.cancel();
alarmClock = null;
} }
// Remove all the timer notifications from the timer table. // Remove all the timer notifications from the timer table.
...@@ -906,8 +900,7 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -906,8 +900,7 @@ public class Timer extends NotificationBroadcasterSupport
Object[] obj = timerTable.get(id); Object[] obj = timerTable.get(id);
if (obj != null) { if (obj != null) {
Long period = (Long)obj[TIMER_PERIOD_INDEX]; return (Long)obj[TIMER_PERIOD_INDEX];
return (new Long(period.longValue()));
} }
return null; return null;
} }
...@@ -924,8 +917,7 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -924,8 +917,7 @@ public class Timer extends NotificationBroadcasterSupport
Object[] obj = timerTable.get(id); Object[] obj = timerTable.get(id);
if (obj != null) { if (obj != null) {
Long nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX]; return (Long)obj[TIMER_NB_OCCUR_INDEX];
return (new Long(nbOccurences.longValue()));
} }
return null; return null;
} }
...@@ -1096,7 +1088,7 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -1096,7 +1088,7 @@ public class Timer extends NotificationBroadcasterSupport
if ((nbOccurences.longValue() == 0) || (nbOccurences.longValue() > 1)) { if ((nbOccurences.longValue() == 0) || (nbOccurences.longValue() > 1)) {
date.setTime(date.getTime() + period.longValue()); date.setTime(date.getTime() + period.longValue());
obj[TIMER_NB_OCCUR_INDEX] = new Long(java.lang.Math.max(0L, (nbOccurences.longValue() - 1))); obj[TIMER_NB_OCCUR_INDEX] = Long.valueOf(java.lang.Math.max(0L, (nbOccurences.longValue() - 1)));
nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX]; nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX];
if (isActive == true) { if (isActive == true) {
...@@ -1146,9 +1138,6 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -1146,9 +1138,6 @@ public class Timer extends NotificationBroadcasterSupport
// // Ignore... // // Ignore...
// } // }
alarmClock.cancel(); alarmClock.cancel();
// Remove the reference on the TimerAlarmClock.
//
alarmClock = null;
} }
timerTable.remove(notifID); timerTable.remove(notifID);
} }
...@@ -1165,10 +1154,6 @@ public class Timer extends NotificationBroadcasterSupport ...@@ -1165,10 +1154,6 @@ public class Timer extends NotificationBroadcasterSupport
// } // }
alarmClock.cancel(); alarmClock.cancel();
// Remove the reference on the TimerAlarmClock.
//
alarmClock = null;
} }
timerTable.remove(notifID); timerTable.remove(notifID);
} }
......
/*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6701459
* @summary Test sequence numbers in RelationService notifications.
* @author Eamonn McManus
*/
/*
* Bug 6701459 is for a synchronization problem that is very unlikely to occur
* in practice and it would be very hard to test it. Instead we just check that
* the fix has not introduced any obviously-wrong behavior in the sequence
* numbers.
*/
import java.util.Arrays;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import javax.management.JMX;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import javax.management.relation.RelationServiceMBean;
import javax.management.relation.Role;
import javax.management.relation.RoleInfo;
import javax.management.relation.RoleList;
public class RelationNotificationSeqNoTest {
public static void main(String[] args) throws Exception {
MBeanServer mbs = MBeanServerFactory.newMBeanServer();
ObjectName relSvcName = new ObjectName("a:type=relationService");
RelationServiceMBean relSvc =
JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class);
mbs.createMBean("javax.management.relation.RelationService",
relSvcName,
new Object[] {Boolean.TRUE},
new String[] {"boolean"});
final BlockingQueue<Notification> q =
new ArrayBlockingQueue<Notification>(100);
NotificationListener qListener = new NotificationListener() {
public void handleNotification(Notification notification,
Object handback) {
q.add(notification);
}
};
mbs.addNotificationListener(relSvcName, qListener, null, null);
RoleInfo leftInfo =
new RoleInfo("left", "javax.management.timer.TimerMBean");
RoleInfo rightInfo =
new RoleInfo("right", "javax.management.timer.Timer");
relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo});
ObjectName timer1 = new ObjectName("a:type=timer,number=1");
ObjectName timer2 = new ObjectName("a:type=timer,number=2");
mbs.createMBean("javax.management.timer.Timer", timer1);
mbs.createMBean("javax.management.timer.Timer", timer2);
Role leftRole =
new Role("left", Arrays.asList(new ObjectName[] {timer1}));
Role rightRole =
new Role("right", Arrays.asList(new ObjectName[] {timer2}));
RoleList roles =
new RoleList(Arrays.asList(new Role[] {leftRole, rightRole}));
final int NREPEAT = 10;
for (int i = 0; i < NREPEAT; i++) {
relSvc.createRelation("relationName", "typeName", roles);
relSvc.removeRelation("relationName");
}
Notification firstNotif = q.remove();
long seqNo = firstNotif.getSequenceNumber();
for (int i = 0; i < NREPEAT * 2 - 1; i++) {
Notification n = q.remove();
long nSeqNo = n.getSequenceNumber();
if (nSeqNo != seqNo + 1) {
throw new Exception(
"TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " +
nSeqNo);
}
seqNo++;
}
System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " +
"with contiguous sequence numbers");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册