You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/08/26 11:52:12 UTC
svn commit: r1620546 -
/tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
Author: markt
Date: Tue Aug 26 09:52:11 2014
New Revision: 1620546
URL: http://svn.apache.org/r1620546
Log:
Ensure info is only calculated once
Modified:
tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java?rev=1620546&r1=1620545&r2=1620546&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java Tue Aug 26 09:52:11 2014
@@ -60,7 +60,7 @@ public class ManagedBean implements java
* The <code>ModelMBeanInfo</code> object that corresponds
* to this <code>ManagedBean</code> instance.
*/
- private transient MBeanInfo info = null;
+ private transient volatile MBeanInfo info = null;
private Map<String,AttributeInfo> attributes = new HashMap<>();
@@ -357,8 +357,9 @@ public class ManagedBean implements java
Lock l = mBeanInfoLock.readLock();
l.lock();
try {
- if (info != null)
+ if (info != null) {
return info;
+ }
} finally {
l.unlock();
}
@@ -366,34 +367,36 @@ public class ManagedBean implements java
l = mBeanInfoLock.writeLock();
l.lock();
try {
- // Create subordinate information descriptors as required
- AttributeInfo attrs[] = getAttributes();
- MBeanAttributeInfo attributes[] =
- new MBeanAttributeInfo[attrs.length];
- for (int i = 0; i < attrs.length; i++)
- attributes[i] = attrs[i].createAttributeInfo();
-
- OperationInfo opers[] = getOperations();
- MBeanOperationInfo operations[] =
- new MBeanOperationInfo[opers.length];
- for (int i = 0; i < opers.length; i++)
- operations[i] = opers[i].createOperationInfo();
-
-
- NotificationInfo notifs[] = getNotifications();
- MBeanNotificationInfo notifications[] =
- new MBeanNotificationInfo[notifs.length];
- for (int i = 0; i < notifs.length; i++)
- notifications[i] = notifs[i].createNotificationInfo();
-
-
- // Construct and return a new ModelMBeanInfo object
- info = new MBeanInfo(getClassName(),
- getDescription(),
- attributes,
- new MBeanConstructorInfo[] {},
- operations,
- notifications);
+ if (info == null) {
+ // Create subordinate information descriptors as required
+ AttributeInfo attrs[] = getAttributes();
+ MBeanAttributeInfo attributes[] =
+ new MBeanAttributeInfo[attrs.length];
+ for (int i = 0; i < attrs.length; i++)
+ attributes[i] = attrs[i].createAttributeInfo();
+
+ OperationInfo opers[] = getOperations();
+ MBeanOperationInfo operations[] =
+ new MBeanOperationInfo[opers.length];
+ for (int i = 0; i < opers.length; i++)
+ operations[i] = opers[i].createOperationInfo();
+
+
+ NotificationInfo notifs[] = getNotifications();
+ MBeanNotificationInfo notifications[] =
+ new MBeanNotificationInfo[notifs.length];
+ for (int i = 0; i < notifs.length; i++)
+ notifications[i] = notifs[i].createNotificationInfo();
+
+
+ // Construct and return a new ModelMBeanInfo object
+ info = new MBeanInfo(getClassName(),
+ getDescription(),
+ attributes,
+ new MBeanConstructorInfo[] {},
+ operations,
+ notifications);
+ }
return info;
} finally {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org