# HG changeset patch # User tbell # Date 1211497128 25200 # Node ID 67f2cb957731a1fdcec4a8d81dcfb27645b2b636 # Parent 67052ac87fc927d048e62ec54ff42adb230d3f7c# Parent a33264d48a843ab7c4c6a737c5d5657d63e1d3db Merge diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java --- a/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Thu May 22 15:58:48 2008 -0700 @@ -233,7 +233,6 @@ MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { - ObjectName logicalName = name; Class theClass; if (className == null) { @@ -519,8 +518,7 @@ QueryExp query) { // Query the MBeans on the repository // - Set list = null; - list = repository.query(name, query); + Set list = repository.query(name, query); if (queryByRepo) { // The repository performs the filtering @@ -576,8 +574,7 @@ private Set queryNamesImpl(ObjectName name, QueryExp query) { // Query the MBeans on the repository // - Set list = null; - list = repository.query(name, query); + Set list = repository.query(name, query); if (queryByRepo) { // The repository performs the filtering @@ -1042,7 +1039,7 @@ if (registerFailed && moi instanceof DynamicMBean2) ((DynamicMBean2) moi).registerFailed(); try { - moi.postRegister(new Boolean(registrationDone)); + moi.postRegister(registrationDone); } catch (RuntimeException e) { throw new RuntimeMBeanException(e, "RuntimeException thrown in postRegister method"); @@ -1094,8 +1091,7 @@ IllegalArgumentException("Object name cannot be null"), "Exception occurred trying to get an MBean"); } - DynamicMBean obj = null; - obj = repository.retrieve(name); + DynamicMBean obj = repository.retrieve(name); if (obj == null) { if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, @@ -1568,7 +1564,6 @@ query.setMBeanServer(server); try { for (NamedObject no : list) { - final DynamicMBean obj = no.getObject(); boolean res; try { res = query.apply(no.getName()); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Thu May 22 15:58:48 2008 -0700 @@ -205,7 +205,7 @@ */ public Object instantiate(Class theClass) throws ReflectionException, MBeanException { - Object moi = null; + Object moi; // ------------------------------ @@ -265,7 +265,7 @@ // ------------------------------ // ------------------------------ final Class[] tab; - Object moi= null; + Object moi; try { // Build the signature of the method // @@ -283,8 +283,7 @@ } // Query the metadata service to get the right constructor - Constructor cons = null; - cons = findConstructor(theClass, tab); + Constructor cons = findConstructor(theClass, tab); if (cons == null) { throw new ReflectionException(new @@ -408,7 +407,7 @@ throw new RuntimeOperationsException(new IllegalArgumentException(), "Null className passed in parameter"); } - Class theClass = null; + Class theClass; if (loaderName == null) { // Load the class using the agent class loader theClass = findClass(className, loader); @@ -621,7 +620,7 @@ static Class loadClass(String className, ClassLoader loader) throws ReflectionException { - Class theClass = null; + Class theClass; if (className == null) { throw new RuntimeOperationsException(new IllegalArgumentException("The class name cannot be null"), diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Thu May 22 15:58:48 2008 -0700 @@ -89,7 +89,6 @@ /* This class is used to match an ObjectName against a pattern. */ private final static class ObjectNamePattern { - private final char[] domain; private final String[] keys; private final String[] values; private final String properties; @@ -106,8 +105,7 @@ * @param pattern The ObjectName pattern under examination. **/ public ObjectNamePattern(ObjectName pattern) { - this(pattern.getDomain(), - pattern.isPropertyListPattern(), + this(pattern.isPropertyListPattern(), pattern.isPropertyValuePattern(), pattern.getCanonicalKeyPropertyListString(), pattern.getKeyPropertyList(), @@ -124,13 +122,11 @@ * @param keyPropertyList pattern.getKeyPropertyList(). * @param pattern The ObjectName pattern under examination. **/ - ObjectNamePattern(String domain, - boolean propertyListPattern, + ObjectNamePattern(boolean propertyListPattern, boolean propertyValuePattern, String canonicalProps, Map keyPropertyList, ObjectName pattern) { - this.domain = domain.toCharArray(); this.isPropertyListPattern = propertyListPattern; this.isPropertyValuePattern = propertyValuePattern; this.properties = canonicalProps; @@ -538,7 +534,7 @@ // "domain:*", "domain:[key=value],*" : names in the specified domain // Surely one of the most frequent case ... query on the whole world - ObjectName name = null; + ObjectName name; if (pattern == null || pattern.getCanonicalName().length() == 0 || pattern.equals(ObjectName.WILDCARD)) @@ -660,7 +656,7 @@ * @return Number of MBeans. */ public Integer getCount() { - return new Integer(nbElements); + return nbElements; } /** @@ -669,7 +665,7 @@ * * @return A string giving the name of the default domain name. */ - public String getDefaultDomain() { + public String getDefaultDomain() { return domain; } diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java --- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Thu May 22 15:58:48 2008 -0700 @@ -435,7 +435,6 @@ clientSequenceNumber = nr.getNextSequenceNumber(); - final int size = infoList.size(); listeners = new HashMap(); for (int i = 0 ; i < len ; i++) { @@ -792,9 +791,6 @@ private Thread currentFetchThread; - // admin stuff - private boolean inited = false; - // state /** * This state means that a thread is being created for fetching and forwarding notifications. diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java --- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Thu May 22 15:58:48 2008 -0700 @@ -269,7 +269,7 @@ ", the maxNotifications is " + maxNotifications); } - NotificationResult nr = null; + NotificationResult nr; final long t = Math.min(connectionTimeout, timeout); try { nr = notifBuffer.fetchNotifications(bufferFilter, @@ -322,7 +322,7 @@ private Integer getListenerID() { synchronized(listenerCounterLock) { - return new Integer(listenerCounter++); + return listenerCounter++; } } @@ -336,7 +336,7 @@ SecurityManager sm = System.getSecurityManager(); if (sm != null) { AccessControlContext acc = AccessController.getContext(); - ObjectInstance oi = null; + ObjectInstance oi; try { oi = AccessController.doPrivileged( new PrivilegedExceptionAction() { diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java --- a/jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java Thu May 22 15:58:48 2008 -0700 @@ -437,7 +437,7 @@ // get the username and password getUsernamePassword(usePasswdFromSharedState); - String localPassword = null; + String localPassword; // userCredentials is initialized in login() if (((localPassword = userCredentials.getProperty(username)) == null) || @@ -487,10 +487,14 @@ throw ace; } } - BufferedInputStream bis = new BufferedInputStream(fis); - userCredentials = new Properties(); - userCredentials.load(bis); - bis.close(); + try { + BufferedInputStream bis = new BufferedInputStream(fis); + userCredentials = new Properties(); + userCredentials.load(bis); + bis.close(); + } finally { + fis.close(); + } } /** diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java --- a/jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java Thu May 22 15:58:48 2008 -0700 @@ -295,7 +295,7 @@ private static class FileLoginConfig extends Configuration { // The JAAS configuration for file-based authentication - private static AppConfigurationEntry[] entries; + private AppConfigurationEntry[] entries; // The classname of the login module for file-based authentication private static final String FILE_LOGIN_MODULE = diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java --- a/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java Thu May 22 15:58:48 2008 -0700 @@ -231,10 +231,13 @@ private static Properties propertiesFromFile(String fname) throws IOException { FileInputStream fin = new FileInputStream(fname); - Properties p = new Properties(); - p.load(fin); - fin.close(); - return p; + try { + Properties p = new Properties(); + p.load(fin); + return p; + } finally { + fin.close(); + } } private void checkAccessLevel(String accessLevel) { diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/NumericValueExp.java --- a/jdk/src/share/classes/javax/management/NumericValueExp.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/NumericValueExp.java Thu May 22 15:58:48 2008 -0700 @@ -83,7 +83,7 @@ *

The serialVersionUID of this class is -4679739485102359104L. */ private static final ObjectStreamField[] serialPersistentFields; - private Number val = new Double(0); + private Number val = 0.0; private static boolean compat = false; static { @@ -213,11 +213,11 @@ } if (isLong) { - this.val = new Long(longVal); + this.val = longVal; } else { - this.val = new Double(doubleVal); + this.val = doubleVal; } } else diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/ObjectName.java --- a/jdk/src/share/classes/javax/management/ObjectName.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/ObjectName.java Thu May 22 15:58:48 2008 -0700 @@ -449,7 +449,7 @@ // parses domain part domain_parsing: while (index < len) { - switch (c = name_chars[index]) { + switch (name_chars[index]) { case ':' : _domain_length = index++; break domain_parsing; @@ -619,7 +619,7 @@ case '\n' : final String ichar = ((c1=='\n')?"\\n":""+c1); throw new MalformedObjectNameException( - "Invalid character '" + c1 + + "Invalid character '" + ichar + "' in value part of property"); default : in_index++; diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/StandardMBean.java --- a/jdk/src/share/classes/javax/management/StandardMBean.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/StandardMBean.java Thu May 22 15:58:48 2008 -0700 @@ -750,7 +750,7 @@ * @return the Descriptor for the new MBeanInfo. */ Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) { - ImmutableDescriptor desc = null; + ImmutableDescriptor desc; if (info == null || info.getDescriptor() == null || info.getDescriptor().getFieldNames().length == 0) { diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/loading/MLet.java --- a/jdk/src/share/classes/javax/management/loading/MLet.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/loading/MLet.java Thu May 22 15:58:48 2008 -0700 @@ -591,8 +591,8 @@ // Instantiate the class specified in the // CODE or OBJECT section of the MLet tag // - Object o = null; - ObjectInstance objInst = null; + Object o; + ObjectInstance objInst; if (code != null && serName != null) { final String msg = @@ -1131,11 +1131,17 @@ return null; } finally { // Cleanup ... - if (tmpFile!=null) try { - tmpFile.delete(); - } catch (Exception x) { - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(), - "getTmpDir", "Failed to delete temporary file", x); + if (tmpFile!=null) { + try { + boolean deleted = tmpFile.delete(); + if (!deleted) { + 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 @@ * Removes any white space from a string. This is used to * convert strings such as "Windows NT" to "WindowsNT". */ - private String removeSpace(String s) { - s = s.trim(); - 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; + private static String removeSpace(String s) { + return s.trim().replace(" ", ""); } /** diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/loading/MLetParser.java --- a/jdk/src/share/classes/javax/management/loading/MLetParser.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/loading/MLetParser.java Thu May 22 15:58:48 2008 -0700 @@ -240,14 +240,12 @@ MLET_LOGGER.logp(Level.FINER, MLetParser.class.getName(), mth, requiresCodeWarning); - atts = null; throw new IOException(requiresCodeWarning); } if (atts.get("archive") == null) { MLET_LOGGER.logp(Level.FINER, MLetParser.class.getName(), mth, requiresJarsWarning); - atts = null; throw new IOException(requiresJarsWarning); } } @@ -265,7 +263,7 @@ public List parseURL(String urlname) throws IOException { // Parse the document // - URL url = null; + URL url; if (urlname.indexOf(':') <= 1) { String userDir = System.getProperty("user.dir"); String prot; diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java --- a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java Thu May 22 15:58:48 2008 -0700 @@ -591,8 +591,6 @@ Set returnedSet = descriptorMap.entrySet(); int i = 0; - Object currValue = null; - Map.Entry currElement = null; if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { MODELMBEAN_LOGGER.logp(Level.FINEST, @@ -600,7 +598,7 @@ "getFields()", "Returning " + numberOfEntries + " fields"); } for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) { - currElement = (Map.Entry) iter.next(); + Map.Entry currElement = (Map.Entry) iter.next(); if (currElement == null) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { @@ -609,7 +607,7 @@ "getFields()", "Element is null"); } } else { - currValue = currElement.getValue(); + Object currValue = currElement.getValue(); if (currValue == null) { responseFields[i] = currElement.getKey() + "="; } else { @@ -1127,7 +1125,7 @@ final char c = entities[i].charAt(0); final String entity = entities[i].substring(1); charToEntityMap[c] = entity; - entityToCharMap.put(entity, new Character(c)); + entityToCharMap.put(entity, c); } } @@ -1325,13 +1323,11 @@ // utility to convert to int, returns -2 if bogus. private long toNumeric(String inStr) { - long result = -2; try { - result = java.lang.Long.parseLong(inStr); + return java.lang.Long.parseLong(inStr); } catch (Exception e) { return -2; } - return result; } diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java --- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java Thu May 22 15:58:48 2008 -0700 @@ -432,7 +432,7 @@ */ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { - Descriptor clone = null; + Descriptor clone; if (in == null) { clone = new DescriptorSupport(); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java --- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java Thu May 22 15:58:48 2008 -0700 @@ -393,7 +393,7 @@ * @exception RuntimeOperationsException if Descriptor is invalid */ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { - Descriptor clone = null; + Descriptor clone; if (in == null) { clone = new DescriptorSupport(); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java --- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java Thu May 22 15:58:48 2008 -0700 @@ -944,7 +944,7 @@ * @exception RuntimeOperationsException if Descriptor is invalid */ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { - Descriptor clone = null; + Descriptor clone; if (in == null) { clone = new DescriptorSupport(); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java --- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java Thu May 22 15:58:48 2008 -0700 @@ -328,7 +328,7 @@ * @exception RuntimeOperationsException if Descriptor is invalid */ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { - Descriptor clone = null; + Descriptor clone; if (in == null) { clone = new DescriptorSupport(); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java --- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java Thu May 22 15:58:48 2008 -0700 @@ -424,7 +424,7 @@ */ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { - Descriptor clone = null; + Descriptor clone; if (in == null) { clone = new DescriptorSupport(); MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java --- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Thu May 22 15:58:48 2008 -0700 @@ -1425,9 +1425,7 @@ } /* Check attributeDescriptor for getMethod */ - ModelMBeanAttributeInfo attrInfo=null; - Descriptor attrDescr=null; - Object response = null; + Object response; try { if (modelMBeanInfo == null) @@ -1435,14 +1433,14 @@ "getAttribute failed: ModelMBeanInfo not found for "+ attrName); - attrInfo = modelMBeanInfo.getAttribute(attrName); + ModelMBeanAttributeInfo attrInfo = modelMBeanInfo.getAttribute(attrName); Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor(); if (attrInfo == null) throw new AttributeNotFoundException("getAttribute failed:"+ " ModelMBeanAttributeInfo not found for " + attrName); - attrDescr = attrInfo.getDescriptor(); + Descriptor attrDescr = attrInfo.getDescriptor(); if (attrDescr != null) { if (!attrInfo.isReadable()) throw new AttributeNotFoundException( @@ -1684,14 +1682,13 @@ "getAttributes(String[])","Entry"); } - AttributeList responseList = null; if (attrNames == null) throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames must not be null"), "Exception occurred trying to get attributes of a "+ "RequiredModelMBean"); - responseList = new AttributeList(); + AttributeList responseList = new AttributeList(); for (int i = 0; i < attrNames.length; i++) { try { responseList.add(new Attribute(attrNames[i], @@ -1833,8 +1830,6 @@ throw new AttributeNotFoundException("setAttribute failed: " + attrName + " is not writable "); - Object setResponse = null; - String attrSetMethod = (String) (attrDescr.getFieldValue("setMethod")); String attrGetMethod = (String) @@ -1873,9 +1868,9 @@ } updateDescriptor = true; } else { - setResponse = invoke(attrSetMethod, - (new Object[] {attrValue}), - (new String[] {attrType}) ); + invoke(attrSetMethod, + (new Object[] {attrValue}), + (new String[] {attrType}) ); } /* change cached value */ @@ -2023,8 +2018,6 @@ private synchronized void writeToLog(String logFileName, String logEntry) throws Exception { - PrintStream logOut = null; - FileOutputStream fos = null; if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), @@ -2041,9 +2034,9 @@ return; } + FileOutputStream fos = new FileOutputStream(logFileName, true); try { - fos = new FileOutputStream(logFileName, true); - logOut = new PrintStream(fos); + PrintStream logOut = new PrintStream(fos); logOut.println(logEntry); logOut.close(); if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { @@ -2062,6 +2055,8 @@ logFileName); } throw e; + } finally { + fos.close(); } } diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/monitor/CounterMonitor.java --- a/jdk/src/share/classes/javax/management/monitor/CounterMonitor.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/monitor/CounterMonitor.java Thu May 22 15:58:48 2008 -0700 @@ -740,16 +740,16 @@ // switch (o.getType()) { case INTEGER: - o.setThreshold(new Integer((int)threshold_value)); + o.setThreshold(Integer.valueOf((int)threshold_value)); break; case BYTE: - o.setThreshold(new Byte((byte)threshold_value)); + o.setThreshold(Byte.valueOf((byte)threshold_value)); break; case SHORT: - o.setThreshold(new Short((short)threshold_value)); + o.setThreshold(Short.valueOf((short)threshold_value)); break; case LONG: - o.setThreshold(new Long(threshold_value)); + o.setThreshold(Long.valueOf(threshold_value)); break; default: // Should never occur... @@ -810,10 +810,10 @@ derived += modulus.longValue(); switch (o.getType()) { - case INTEGER: o.setDerivedGauge(new Integer((int) derived)); break; - case BYTE: o.setDerivedGauge(new Byte((byte) derived)); break; - case SHORT: o.setDerivedGauge(new Short((short) derived)); break; - case LONG: o.setDerivedGauge(new Long(derived)); break; + case INTEGER: o.setDerivedGauge(Integer.valueOf((int) derived)); break; + case BYTE: o.setDerivedGauge(Byte.valueOf((byte) derived)); break; + case SHORT: o.setDerivedGauge(Short.valueOf((short) derived)); break; + case LONG: o.setDerivedGauge(Long.valueOf(derived)); break; default: // Should never occur... MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(), diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java --- a/jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java Thu May 22 15:58:48 2008 -0700 @@ -636,28 +636,28 @@ Number der; switch (o.getType()) { case INTEGER: - der = new Integer(((Integer)scanGauge).intValue() - - ((Integer)prev).intValue()); + der = Integer.valueOf(((Integer)scanGauge).intValue() - + ((Integer)prev).intValue()); break; case BYTE: - der = new Byte((byte)(((Byte)scanGauge).byteValue() - - ((Byte)prev).byteValue())); + der = Byte.valueOf((byte)(((Byte)scanGauge).byteValue() - + ((Byte)prev).byteValue())); break; case SHORT: - der = new Short((short)(((Short)scanGauge).shortValue() - - ((Short)prev).shortValue())); + der = Short.valueOf((short)(((Short)scanGauge).shortValue() - + ((Short)prev).shortValue())); break; case LONG: - der = new Long(((Long)scanGauge).longValue() - - ((Long)prev).longValue()); + der = Long.valueOf(((Long)scanGauge).longValue() - + ((Long)prev).longValue()); break; case FLOAT: - der = new Float(((Float)scanGauge).floatValue() - - ((Float)prev).floatValue()); + der = Float.valueOf(((Float)scanGauge).floatValue() - + ((Float)prev).floatValue()); break; case DOUBLE: - der = new Double(((Double)scanGauge).doubleValue() - - ((Double)prev).doubleValue()); + der = Double.valueOf(((Double)scanGauge).doubleValue() - + ((Double)prev).doubleValue()); break; default: // Should never occur... diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/monitor/Monitor.java --- a/jdk/src/share/classes/javax/management/monitor/Monitor.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/monitor/Monitor.java Thu May 22 15:58:48 2008 -0700 @@ -367,7 +367,7 @@ /** * 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 @@ */ private void monitor(ObservedObject o, int index, int an[]) { - String attribute = null; + String attribute; String notifType = null; String msg = null; Object derGauge = null; Object trigger = null; - ObjectName object = null; + ObjectName object; Comparable value = null; MonitorNotification alarm = null; @@ -1565,7 +1565,7 @@ final ThreadGroup group; final AtomicInteger threadNumber = new AtomicInteger(1); final String namePrefix; - final String nameSuffix = "]"; + static final String nameSuffix = "]"; public DaemonThreadFactory(String poolName) { SecurityManager s = System.getSecurityManager(); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/ArrayType.java --- a/jdk/src/share/classes/javax/management/openmbean/ArrayType.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/ArrayType.java Thu May 22 15:58:48 2008 -0700 @@ -726,7 +726,7 @@ value += dimension; value += elementType.hashCode(); value += Boolean.valueOf(primitiveArray).hashCode(); - myHashCode = new Integer(value); + myHashCode = Integer.valueOf(value); } // return always the same hash code for this instance (immutable) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/CompositeType.java --- a/jdk/src/share/classes/javax/management/openmbean/CompositeType.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/CompositeType.java Thu May 22 15:58:48 2008 -0700 @@ -426,7 +426,7 @@ value += 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) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java --- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Thu May 22 15:58:48 2008 -0700 @@ -769,7 +769,6 @@ "array with same dimensions"; throw new IllegalArgumentException(msg); } - Class targetComponentClass = targetArrayClass.getComponentType(); OpenType componentOpenType; if (dim == 1) componentOpenType = baseType; diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java --- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java Thu May 22 15:58:48 2008 -0700 @@ -252,7 +252,7 @@ int value = 0; value += this.getName().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) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java --- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java Thu May 22 15:58:48 2008 -0700 @@ -347,7 +347,7 @@ value += arraySetHash(this.getConstructors()); value += arraySetHash(this.getOperations()); value += arraySetHash(this.getNotifications()); - myHashCode = new Integer(value); + myHashCode = Integer.valueOf(value); } // return always the same hash code for this instance (immutable) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfoSupport.java --- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfoSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfoSupport.java Thu May 22 15:58:48 2008 -0700 @@ -352,7 +352,7 @@ value += Arrays.asList(this.getSignature()).hashCode(); value += this.getReturnOpenType().hashCode(); value += this.getImpact(); - myHashCode = new Integer(value); + myHashCode = Integer.valueOf(value); } // return always the same hash code for this instance (immutable) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/SimpleType.java --- a/jdk/src/share/classes/javax/management/openmbean/SimpleType.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/SimpleType.java Thu May 22 15:58:48 2008 -0700 @@ -257,7 +257,7 @@ // Calculate the hash code value if it has not yet been done (ie 1st call to hashCode()) // 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) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/openmbean/TabularType.java --- a/jdk/src/share/classes/javax/management/openmbean/TabularType.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/openmbean/TabularType.java Thu May 22 15:58:48 2008 -0700 @@ -332,7 +332,7 @@ for (Iterator k = indexNames.iterator(); k.hasNext(); ) { value += k.next().hashCode(); } - myHashCode = new Integer(value); + myHashCode = Integer.valueOf(value); } // return always the same hash code for this instance (immutable) diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/relation/RelationNotification.java --- a/jdk/src/share/classes/javax/management/relation/RelationNotification.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/relation/RelationNotification.java Thu May 22 15:58:48 2008 -0700 @@ -369,7 +369,7 @@ * @return a {@link List} of {@link ObjectName}. */ public List getMBeansToUnregister() { - List result = null; + List result; if (unregisterMBeanList != null) { result = new ArrayList(unregisterMBeanList); } else { @@ -397,7 +397,7 @@ * @return the old value of the updated role. */ public List getOldRoleValue() { - List result = null; + List result; if (oldRoleValue != null) { result = new ArrayList(oldRoleValue); } else { @@ -412,7 +412,7 @@ * @return the new value of the updated role. */ public List getNewRoleValue() { - List result = null; + List result; if (newRoleValue != null) { result = new ArrayList(newRoleValue); } else { diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/relation/RelationService.java --- a/jdk/src/share/classes/javax/management/relation/RelationService.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/relation/RelationService.java Thu May 22 15:58:48 2008 -0700 @@ -35,6 +35,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Level; import javax.management.Attribute; @@ -122,7 +123,7 @@ // Internal counter to provide sequence numbers for notifications sent 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 private ObjectName myObjName = null; @@ -256,19 +257,6 @@ 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 // @@ -369,7 +357,7 @@ * @return ArrayList of relation type names (Strings) */ public List getAllRelationTypeNames() { - ArrayList result = null; + ArrayList result; synchronized(myRelType2ObjMap) { result = new ArrayList(myRelType2ObjMap.keySet()); } @@ -684,7 +672,7 @@ // Can throw InstanceNotFoundException (but detected above) // No MBeanException as no exception raised by this method, and no // ReflectionException - String relId = null; + String relId; try { relId = (String)(myMBeanServer.getAttribute(relationObjectName, "RelationId")); @@ -707,7 +695,7 @@ // Can throw InstanceNotFoundException (but detected above) // No MBeanException as no exception raised by this method, no // ReflectionException - ObjectName relServObjName = null; + ObjectName relServObjName; try { relServObjName = (ObjectName) (myMBeanServer.getAttribute(relationObjectName, @@ -737,7 +725,7 @@ // Can throw InstanceNotFoundException (but detected above) // No MBeanException as no exception raised by this method, no // ReflectionException - String relTypeName = null; + String relTypeName; try { relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName, "RelationTypeName")); @@ -758,7 +746,7 @@ // Can throw InstanceNotFoundException (but detected above) // No MBeanException as no exception raised by this method, no // ReflectionException - RoleList roleList = null; + RoleList roleList; try { roleList = (RoleList)(myMBeanServer.invoke(relationObjectName, "retrieveAllRoles", @@ -912,7 +900,7 @@ * @return ArrayList of String */ public List getAllRelationIds() { - List result = null; + List result; synchronized(myRelId2ObjMap) { result = new ArrayList(myRelId2ObjMap.keySet()); } @@ -948,7 +936,7 @@ RELATION_LOGGER.entering(RelationService.class.getName(), "checkRoleReading", new Object[] {roleName, relationTypeName}); - Integer result = null; + Integer result; // Can throw a RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); @@ -965,7 +953,7 @@ false); } 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(), @@ -1021,13 +1009,13 @@ writeChkFlag = false; } - RoleInfo roleInfo = null; + RoleInfo roleInfo; try { roleInfo = relType.getRoleInfo(roleName); } catch (RoleInfoNotFoundException exc) { RELATION_LOGGER.exiting(RelationService.class.getName(), "checkRoleWriting"); - return new Integer(RoleStatus.NO_ROLE_WITH_NAME); + return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME); } Integer result = checkRoleInt(2, @@ -1436,7 +1424,7 @@ // Relation id to relation type name map // First retrieves the relation type name - String relTypeName = null; + String relTypeName; synchronized(myRelId2RelTypeMap) { relTypeName = myRelId2RelTypeMap.get(relationId); myRelId2RelTypeMap.remove(relationId); @@ -1641,7 +1629,7 @@ // List of relation ids of interest regarding the selected // relation type - List relIdList = null; + List relIdList; if (relationTypeName == null) { // Considers all relations relIdList = new ArrayList(allRelIdSet); @@ -1655,7 +1643,7 @@ for (String currRelId : allRelIdSet) { // Retrieves its relation type - String currRelTypeName = null; + String currRelTypeName; synchronized(myRelId2RelTypeMap) { currRelTypeName = myRelId2RelTypeMap.get(currRelId); @@ -1952,7 +1940,7 @@ // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); - RoleResult result = null; + RoleResult result; if (relObj instanceof RelationSupport) { // Internal relation @@ -2022,7 +2010,7 @@ // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); - RoleResult result = null; + RoleResult result; if (relObj instanceof RelationSupport) { // Internal relation @@ -2073,7 +2061,7 @@ // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); - Integer result = null; + Integer result; if (relObj instanceof RelationSupport) { // Internal relation @@ -2268,7 +2256,7 @@ // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); - RoleResult result = null; + RoleResult result; if (relObj instanceof RelationSupport) { // Internal relation @@ -2390,7 +2378,7 @@ // Can throw a RelationNotFoundException Object relObj = getRelation(relationId); - String result = null; + String result; if (relObj instanceof RelationSupport) { // Internal relation @@ -2473,7 +2461,7 @@ // Note: do both tests as a relation can be an MBean and be // itself referenced in another relation :) - String relId = null; + String relId; synchronized(myRelMBeanObjName2RelIdMap){ relId = myRelMBeanObjName2RelIdMap.get(mbeanName); } @@ -2511,9 +2499,6 @@ RELATION_LOGGER.entering(RelationService.class.getName(), "getNotificationInfo"); - MBeanNotificationInfo[] ntfInfoArray = - new MBeanNotificationInfo[1]; - String ntfClass = "javax.management.relation.RelationNotification"; String[] ntfTypes = new String[] { @@ -2615,7 +2600,7 @@ "getRelationType", relationTypeName); // No null relation type accepted, so can use get() - RelationType relType = null; + RelationType relType; synchronized(myRelType2ObjMap) { relType = (myRelType2ObjMap.get(relationTypeName)); } @@ -2659,7 +2644,7 @@ "getRelation", relationId); // No null relation accepted, so can use get() - Object rel = null; + Object rel; synchronized(myRelId2ObjMap) { rel = myRelId2ObjMap.get(relationId); } @@ -3077,7 +3062,7 @@ // Retrieves corresponding role info // Can throw a RoleInfoNotFoundException to be converted into a // RoleNotFoundException - RoleInfo roleInfo = null; + RoleInfo roleInfo; try { roleInfo = relType.getRoleInfo(currRoleName); } catch (RoleInfoNotFoundException exc) { @@ -3227,7 +3212,7 @@ if (!(roleName.equals(expName))) { RELATION_LOGGER.exiting(RelationService.class.getName(), "checkRoleInt"); - return new Integer(RoleStatus.NO_ROLE_WITH_NAME); + return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME); } // Checks read access if required @@ -3236,7 +3221,7 @@ if (!isReadable) { RELATION_LOGGER.exiting(RelationService.class.getName(), "checkRoleInt"); - return new Integer(RoleStatus.ROLE_NOT_READABLE); + return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE); } else { // End of check :) RELATION_LOGGER.exiting(RelationService.class.getName(), @@ -3572,7 +3557,7 @@ // Relation type name // Note: do not use getRelationTypeName() as if it is a relation MBean // it is already unregistered. - String relTypeName = null; + String relTypeName; synchronized(myRelId2RelTypeMap) { relTypeName = (myRelId2RelTypeMap.get(relationId)); } @@ -3609,7 +3594,7 @@ } // Sequence number - Long seqNbr = getNotificationSequenceNumber(); + Long seqNo = atomicSeqNo.incrementAndGet(); // Timestamp Date currDate = new Date(); @@ -3625,7 +3610,7 @@ // Creation or removal ntf = new RelationNotification(ntfType, this, - seqNbr.longValue(), + seqNo.longValue(), timeStamp, message, relationId, @@ -3640,7 +3625,7 @@ // Update ntf = new RelationNotification(ntfType, this, - seqNbr.longValue(), + seqNo.longValue(), timeStamp, message, relationId, @@ -3732,7 +3717,7 @@ // // Shall not throw RelationTypeNotFoundException or // RoleInfoNotFoundException - RoleInfo currRoleInfo = null; + RoleInfo currRoleInfo; try { currRoleInfo = getRoleInfo(currRelTypeName, currRoleName); diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/relation/RelationSupport.java --- a/jdk/src/share/classes/javax/management/relation/RelationSupport.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/relation/RelationSupport.java Thu May 22 15:58:48 2008 -0700 @@ -34,6 +34,7 @@ import java.util.Map; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER; import static com.sun.jmx.mbeanserver.Util.cast; import javax.management.InstanceNotFoundException; @@ -110,7 +111,7 @@ private Map myRoleName2ValueMap = new HashMap(); // Flag to indicate if the object has been added in the Relation Service - private Boolean myInRelServFlg = null; + private final AtomicBoolean myInRelServFlg = new AtomicBoolean(); // // Constructors @@ -403,7 +404,7 @@ "getRoleCardinality", roleName); // Try to retrieve the role - Role role = null; + Role role; synchronized(myRoleName2ValueMap) { // No null Role is allowed, so direct use of get() role = (myRoleName2ValueMap.get(roleName)); @@ -427,7 +428,7 @@ RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoleCardinality"); - return new Integer(roleValue.size()); + return roleValue.size(); } /** @@ -701,11 +702,7 @@ * the Relation Service. */ public Boolean isInRelationService() { - Boolean result = null; - synchronized(myInRelServFlg) { - result = Boolean.valueOf(myInRelServFlg.booleanValue()); - } - return result; + return myInRelServFlg.get(); } public void setRelationServiceManagementFlag(Boolean flag) @@ -715,10 +712,7 @@ String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } - synchronized(myInRelServFlg) { - myInRelServFlg = Boolean.valueOf(flag.booleanValue()); - } - return; + myInRelServFlg.set(flag); } // @@ -790,7 +784,7 @@ int pbType = 0; - Role role = null; + Role role; synchronized(myRoleName2ValueMap) { // No null Role is allowed, so direct use of get() role = (myRoleName2ValueMap.get(roleName)); @@ -801,7 +795,7 @@ } else { // Checks if the role is readable - Integer status = null; + Integer status; if (relationServCallFlg) { @@ -851,7 +845,7 @@ pbType = status.intValue(); } - Object result = null; + Object result; if (pbType == 0) { // Role can be retrieved @@ -937,7 +931,7 @@ for (int i = 0; i < roleNameArray.length; i++) { String currRoleName = roleNameArray[i]; - Object currResult = null; + Object currResult; // Can throw RelationServiceNotRegisteredException // @@ -1102,13 +1096,13 @@ // handle initialization of role when creating the relation // (roles provided in the RoleList parameter are directly set but // roles automatically initialized are set using setRole()) - Role role = null; + Role role; synchronized(myRoleName2ValueMap) { role = (myRoleName2ValueMap.get(roleName)); } List oldRoleValue; - Boolean initFlg = null; + Boolean initFlg; if (role == null) { initFlg = true; @@ -1122,7 +1116,7 @@ // Checks if the role can be set: is writable (except if // initialization) and correct value try { - Integer status = null; + Integer status; if (relationServCallFlg) { @@ -1314,7 +1308,7 @@ Object[] params = new Object[3]; params[0] = myRelId; params[1] = newRole; - params[2] = ((ArrayList)oldRoleValue); + params[2] = oldRoleValue; String[] signature = new String[3]; signature[0] = "java.lang.String"; signature[1] = "javax.management.relation.Role"; @@ -1598,7 +1592,6 @@ myRelTypeName = relationTypeName; // Can throw InvalidRoleValueException initRoleMap(list); - myInRelServFlg = Boolean.FALSE; RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers"); return; @@ -1710,7 +1703,7 @@ roleName, relationServCallFlg, relationServ}); // Retrieves current role value - Role role = null; + Role role; synchronized(myRoleName2ValueMap) { role = (myRoleName2ValueMap.get(roleName)); } diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java --- a/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java Thu May 22 15:58:48 2008 -0700 @@ -435,7 +435,7 @@ Iterator providers = getProviderIterator(JMXConnectorProvider.class, loader); - JMXConnector connection = null; + JMXConnector connection; IOException exception = null; while(providers.hasNext()) { try { @@ -450,7 +450,7 @@ "] Service provider exception: " + e); if (!(e instanceof MalformedURLException)) { if (exception == null) { - if (exception instanceof IOException) { + if (e instanceof IOException) { exception = (IOException) e; } else { exception = EnvHelp.initCause( diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java --- a/jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java Thu May 22 15:58:48 2008 -0700 @@ -215,12 +215,10 @@ JMXConnectorFactory. getProviderIterator(JMXConnectorServerProvider.class, loader); - JMXConnectorServer connection = null; IOException exception = null; while (providers.hasNext()) { try { - connection = providers.next().newJMXConnectorServer(url, map, mbs); - return connection; + return providers.next().newJMXConnectorServer(url, map, mbs); } catch (JMXProviderException e) { throw e; } catch (Exception e) { @@ -230,7 +228,7 @@ "] Service provider exception: " + e); if (!(e instanceof MalformedURLException)) { if (exception == null) { - if (exception instanceof IOException) { + if (e instanceof IOException) { exception = (IOException) e; } else { exception = EnvHelp.initCause( diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/remote/JMXServiceURL.java --- a/jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Thu May 22 15:58:48 2008 -0700 @@ -162,8 +162,6 @@ requiredPrefix); } - int[] ptr = new int[1]; - // Parse the protocol name final int protoStart = requiredPrefixLength; final int protoEnd = indexOf(serviceURL, ':', protoStart); @@ -664,11 +662,6 @@ 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()}. */ diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Thu May 22 15:58:48 2008 -0700 @@ -1376,12 +1376,12 @@ protected Integer addListenerForMBeanRemovedNotif() throws IOException, InstanceNotFoundException { - MarshalledObject sFilter = null; NotificationFilterSupport clientFilter = new NotificationFilterSupport(); clientFilter.enableType( MBeanServerNotification.UNREGISTRATION_NOTIFICATION); - sFilter = new MarshalledObject(clientFilter); + MarshalledObject sFilter = + new MarshalledObject(clientFilter); Integer[] listenerIDs; final ObjectName[] names = @@ -1434,7 +1434,7 @@ connectionId, clientNotifCounter++, message, - new Long(number)); + Long.valueOf(number)); sendNotification(n); } } @@ -1593,7 +1593,7 @@ protected void doStart() throws IOException { // Get RMIServer stub from directory or URL encoding if needed. - RMIServer stub = null; + RMIServer stub; try { stub = (rmiServer!=null)?rmiServer: findRMIServer(jmxServiceURL, env); @@ -2532,7 +2532,7 @@ * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to * connect unconnected stubs. **/ - private static WeakReference orb = null; + private static volatile WeakReference orb = null; // TRACES & DEBUG //--------------- diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java --- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java Thu May 22 15:58:48 2008 -0700 @@ -365,7 +365,7 @@ // Access file property specified, create an instance // of the MBeanServerFileAccessController class // - MBeanServerForwarder mbsf = null; + MBeanServerForwarder mbsf; try { mbsf = new MBeanServerFileAccessController(accessFile); } catch (IOException e) { diff -r 67052ac87fc9 -r 67f2cb957731 jdk/src/share/classes/javax/management/timer/Timer.java --- a/jdk/src/share/classes/javax/management/timer/Timer.java Wed Jul 05 16:36:55 2017 +0200 +++ b/jdk/src/share/classes/javax/management/timer/Timer.java Thu May 22 15:58:48 2008 -0700 @@ -344,13 +344,11 @@ // if (isActive == true) { - TimerAlarmClock alarmClock; - for (Object[] obj : timerTable.values()) { // Stop all the TimerAlarmClock. // - alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX]; + TimerAlarmClock alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX]; if (alarmClock != null) { // alarmClock.interrupt(); // try { @@ -364,7 +362,6 @@ // // alarmClock.cancel(); - alarmClock = null; } } @@ -458,8 +455,7 @@ // Create and add the timer notification into the timer table. // - Integer notifID = null; - notifID = new Integer(++counterID); + Integer notifID = Integer.valueOf(++counterID); // The sequenceNumber and the timeStamp attributes are updated // when the notification is emitted by the timer. @@ -486,8 +482,8 @@ obj[TIMER_NOTIF_INDEX] = (Object)notif; obj[TIMER_DATE_INDEX] = (Object)d; - obj[TIMER_PERIOD_INDEX] = (Object) new Long(period); - obj[TIMER_NB_OCCUR_INDEX] = (Object) new Long(nbOccurences); + obj[TIMER_PERIOD_INDEX] = (Object) period; + obj[TIMER_NB_OCCUR_INDEX] = (Object) nbOccurences; obj[ALARM_CLOCK_INDEX] = (Object)alarmClock; obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate); @@ -678,7 +674,6 @@ // // Remove the reference on the TimerAlarmClock. // // alarmClock.cancel(); - alarmClock = null; } // Remove the timer notification from the timer table. @@ -755,7 +750,6 @@ // // } alarmClock.cancel(); - alarmClock = null; } // Remove all the timer notifications from the timer table. @@ -906,8 +900,7 @@ Object[] obj = timerTable.get(id); if (obj != null) { - Long period = (Long)obj[TIMER_PERIOD_INDEX]; - return (new Long(period.longValue())); + return (Long)obj[TIMER_PERIOD_INDEX]; } return null; } @@ -924,8 +917,7 @@ Object[] obj = timerTable.get(id); if (obj != null) { - Long nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX]; - return (new Long(nbOccurences.longValue())); + return (Long)obj[TIMER_NB_OCCUR_INDEX]; } return null; } @@ -1096,7 +1088,7 @@ if ((nbOccurences.longValue() == 0) || (nbOccurences.longValue() > 1)) { 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]; if (isActive == true) { @@ -1146,9 +1138,6 @@ // // Ignore... // } alarmClock.cancel(); - // Remove the reference on the TimerAlarmClock. - // - alarmClock = null; } timerTable.remove(notifID); } @@ -1165,10 +1154,6 @@ // } alarmClock.cancel(); - - // Remove the reference on the TimerAlarmClock. - // - alarmClock = null; } timerTable.remove(notifID); } diff -r 67052ac87fc9 -r 67f2cb957731 jdk/test/javax/management/relation/RelationNotificationSeqNoTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/management/relation/RelationNotificationSeqNoTest.java Thu May 22 15:58:48 2008 -0700 @@ -0,0 +1,112 @@ +/* + * 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 q = + new ArrayBlockingQueue(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"); + } +}