提交 af4b6955 编写于 作者: L lmalvent

6711106: REGRESSION: Bad usage of SnapshotMBeanServerConnection in MBeans tab and JConsole plugins.

Reviewed-by: jfdenise
上级 9f4b0a82
...@@ -37,6 +37,7 @@ import javax.management.*; ...@@ -37,6 +37,7 @@ import javax.management.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import javax.swing.tree.*; import javax.swing.tree.*;
import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection;
import sun.tools.jconsole.inspector.*; import sun.tools.jconsole.inspector.*;
import com.sun.tools.jconsole.JConsoleContext; import com.sun.tools.jconsole.JConsoleContext;
...@@ -154,6 +155,10 @@ public class MBeansTab extends Tab implements ...@@ -154,6 +155,10 @@ public class MBeansTab extends Tab implements
return vmPanel.getProxyClient().getMBeanServerConnection(); return vmPanel.getProxyClient().getMBeanServerConnection();
} }
public SnapshotMBeanServerConnection getSnapshotMBeanServerConnection() {
return vmPanel.getProxyClient().getSnapshotMBeanServerConnection();
}
@Override @Override
public void update() { public void update() {
// Ping the connection to see if it is still alive. At // Ping the connection to see if it is still alive. At
......
...@@ -28,7 +28,6 @@ package sun.tools.jconsole; ...@@ -28,7 +28,6 @@ package sun.tools.jconsole;
import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.tools.jconsole.JConsoleContext; import com.sun.tools.jconsole.JConsoleContext;
import com.sun.tools.jconsole.JConsoleContext.ConnectionState; import com.sun.tools.jconsole.JConsoleContext.ConnectionState;
import java.awt.Component;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.io.IOException; import java.io.IOException;
...@@ -78,6 +77,7 @@ public class ProxyClient implements JConsoleContext { ...@@ -78,6 +77,7 @@ public class ProxyClient implements JConsoleContext {
private String advancedUrl = null; private String advancedUrl = null;
private JMXServiceURL jmxUrl = null; private JMXServiceURL jmxUrl = null;
private MBeanServerConnection mbsc = null;
private SnapshotMBeanServerConnection server = null; private SnapshotMBeanServerConnection server = null;
private JMXConnector jmxc = null; private JMXConnector jmxc = null;
private RMIServer stub = null; private RMIServer stub = null;
...@@ -103,7 +103,6 @@ public class ProxyClient implements JConsoleContext { ...@@ -103,7 +103,6 @@ public class ProxyClient implements JConsoleContext {
private List<MemoryPoolProxy> memoryPoolProxies = null; private List<MemoryPoolProxy> memoryPoolProxies = null;
private List<GarbageCollectorMXBean> garbageCollectorMBeans = null; private List<GarbageCollectorMXBean> garbageCollectorMBeans = null;
private String detectDeadlocksOperation = null;
final static private String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME = final static private String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
"com.sun.management:type=HotSpotDiagnostic"; "com.sun.management:type=HotSpotDiagnostic";
...@@ -326,8 +325,8 @@ public class ProxyClient implements JConsoleContext { ...@@ -326,8 +325,8 @@ public class ProxyClient implements JConsoleContext {
if (jmxUrl == null && "localhost".equals(hostName) && port == 0) { if (jmxUrl == null && "localhost".equals(hostName) && port == 0) {
// Monitor self // Monitor self
this.jmxc = null; this.jmxc = null;
this.server = Snapshot.newSnapshot( this.mbsc = ManagementFactory.getPlatformMBeanServer();
ManagementFactory.getPlatformMBeanServer()); this.server = Snapshot.newSnapshot(mbsc);
} else { } else {
// Monitor another process // Monitor another process
if (lvm != null) { if (lvm != null) {
...@@ -369,7 +368,8 @@ public class ProxyClient implements JConsoleContext { ...@@ -369,7 +368,8 @@ public class ProxyClient implements JConsoleContext {
this.jmxc = JMXConnectorFactory.connect(jmxUrl, env); this.jmxc = JMXConnectorFactory.connect(jmxUrl, env);
} }
} }
this.server = Snapshot.newSnapshot(jmxc.getMBeanServerConnection()); this.mbsc = jmxc.getMBeanServerConnection();
this.server = Snapshot.newSnapshot(mbsc);
} }
this.isDead = false; this.isDead = false;
...@@ -518,7 +518,11 @@ public class ProxyClient implements JConsoleContext { ...@@ -518,7 +518,11 @@ public class ProxyClient implements JConsoleContext {
} }
} }
public MBeanServerConnection getMBeanServerConnection() { public MBeanServerConnection getMBeanServerConnection() {
return mbsc;
}
public SnapshotMBeanServerConnection getSnapshotMBeanServerConnection() {
return server; return server;
} }
......
...@@ -30,6 +30,7 @@ import javax.management.*; ...@@ -30,6 +30,7 @@ import javax.management.*;
import javax.swing.Icon; import javax.swing.Icon;
import sun.tools.jconsole.JConsole; import sun.tools.jconsole.JConsole;
import sun.tools.jconsole.MBeansTab; import sun.tools.jconsole.MBeansTab;
import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection;
public class XMBean { public class XMBean {
...@@ -60,6 +61,10 @@ public class XMBean { ...@@ -60,6 +61,10 @@ public class XMBean {
return mbeansTab.getMBeanServerConnection(); return mbeansTab.getMBeanServerConnection();
} }
SnapshotMBeanServerConnection getSnapshotMBeanServerConnection() {
return mbeansTab.getSnapshotMBeanServerConnection();
}
public Boolean isBroadcaster() { public Boolean isBroadcaster() {
synchronized (broadcasterLock) { synchronized (broadcasterLock) {
if (broadcaster == null) { if (broadcaster == null) {
...@@ -103,14 +108,14 @@ public class XMBean { ...@@ -103,14 +108,14 @@ public class XMBean {
public Object getAttribute(String attributeName) public Object getAttribute(String attributeName)
throws AttributeNotFoundException, InstanceNotFoundException, throws AttributeNotFoundException, InstanceNotFoundException,
MBeanException, ReflectionException, IOException { MBeanException, ReflectionException, IOException {
return getMBeanServerConnection().getAttribute( return getSnapshotMBeanServerConnection().getAttribute(
getObjectName(), attributeName); getObjectName(), attributeName);
} }
public AttributeList getAttributes(String attributeNames[]) public AttributeList getAttributes(String attributeNames[])
throws AttributeNotFoundException, InstanceNotFoundException, throws AttributeNotFoundException, InstanceNotFoundException,
MBeanException, ReflectionException, IOException { MBeanException, ReflectionException, IOException {
return getMBeanServerConnection().getAttributes( return getSnapshotMBeanServerConnection().getAttributes(
getObjectName(), attributeNames); getObjectName(), attributeNames);
} }
......
...@@ -349,7 +349,14 @@ public class XMBeanAttributes extends XTable { ...@@ -349,7 +349,14 @@ public class XMBeanAttributes extends XTable {
try { try {
list = mbean.getAttributes(attributesInfo); list = mbean.getAttributes(attributesInfo);
}catch(Exception e) { } catch (Exception e) {
if (JConsole.isDebug()) {
System.err.println("Error calling getAttributes() on MBean \"" +
mbean.getObjectName() + "\". JConsole will " +
"try to get them individually calling " +
"getAttribute() instead. Exception:");
e.printStackTrace(System.err);
}
list = new AttributeList(); list = new AttributeList();
//Can't load all attributes, do it one after each other. //Can't load all attributes, do it one after each other.
for(int i = 0; i < attributesInfo.length; i++) { for(int i = 0; i < attributesInfo.length; i++) {
...@@ -357,7 +364,7 @@ public class XMBeanAttributes extends XTable { ...@@ -357,7 +364,7 @@ public class XMBeanAttributes extends XTable {
try { try {
name = attributesInfo[i].getName(); name = attributesInfo[i].getName();
Object value = Object value =
mbean.getAttribute(name); mbean.getMBeanServerConnection().getAttribute(mbean.getObjectName(), name);
list.add(new Attribute(name, value)); list.add(new Attribute(name, value));
}catch(Exception ex) { }catch(Exception ex) {
if(attributesInfo[i].isReadable()) { if(attributesInfo[i].isReadable()) {
...@@ -397,8 +404,8 @@ public class XMBeanAttributes extends XTable { ...@@ -397,8 +404,8 @@ public class XMBeanAttributes extends XTable {
// went wrong. // went wrong.
try { try {
Object v = Object v =
mbean.getAttribute(attributeInfo. mbean.getMBeanServerConnection().getAttribute(
getName()); mbean.getObjectName(), attributeInfo.getName());
//What happens if now it is ok? //What happens if now it is ok?
// Be pragmatic, add it to readable... // Be pragmatic, add it to readable...
attributes.put(attributeInfo.getName(), attributes.put(attributeInfo.getName(),
...@@ -528,10 +535,8 @@ public class XMBeanAttributes extends XTable { ...@@ -528,10 +535,8 @@ public class XMBeanAttributes extends XTable {
} }
public void refreshAttributes() { public void refreshAttributes() {
MBeanServerConnection mbsc = mbeansTab.getMBeanServerConnection(); SnapshotMBeanServerConnection mbsc = mbeansTab.getSnapshotMBeanServerConnection();
if (mbsc instanceof SnapshotMBeanServerConnection) { mbsc.flush();
((SnapshotMBeanServerConnection) mbsc).flush();
}
stopCellEditing(); stopCellEditing();
loadAttributes(mbean, mbeanInfo); loadAttributes(mbean, mbeanInfo);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册