[ https://issues.apache.org/jira/browse/GEODE-5455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16554492#comment-16554492 ]
ASF subversion and git services commented on GEODE-5455: -------------------------------------------------------- Commit e4ede167e489f521f906239c90a8714e080125f1 in geode's branch refs/heads/develop from [~khowe] [ https://gitbox.apache.org/repos/asf?p=geode.git;h=e4ede16 ] GEODE-5455: add new tests to verify MemberMXBean method return types (#2169) Verify that JMX MXBean proxy reconstructs correct return type from CompositeDataSupport. Correct type recontruction of types such as OSMetrics requires that the mxbean proxy is intantiated from JMX.newMXBeanProxy() not javax.management.MBeanServerInvocationHandler.newProxyInstance(), which returns an mbean proxy > ClassCastException in MemberMBean.showOSMetrics, OSMetrics is not > reconstructible from CompositeData > ---------------------------------------------------------------------------------------------------- > > Key: GEODE-5455 > URL: https://issues.apache.org/jira/browse/GEODE-5455 > Project: Geode > Issue Type: Bug > Components: jmx > Affects Versions: 1.4.0 > Reporter: Kenneth Howe > Assignee: Kenneth Howe > Priority: Major > Labels: pull-request-available > Time Spent: 20m > Remaining Estimate: 0h > > The following code snippet throws > {code} > Exception in thread "main" java.lang.ClassCastException: > javax.management.openmbean.CompositeDataSupport cannot be cast to > org.apache.geode.management.OSMetrics at > com.sun.proxy.$Proxy0.showOSMetrics(Unknown Source) > {code} > {code:java} > public static MBeanServerConnection getLocalMBeanServerConnectionStatic(int > pid) { > try { > String address = ConnectorAddressLink.importFrom(pid); > JMXServiceURL jmxUrl = new JMXServiceURL(address); > return JMXConnectorFactory.connect(jmxUrl).getMBeanServerConnection(); > } catch (IOException e) { > throw new RuntimeException( > "Of course you still have to implement a good connection handling"); > } > } > public static void main(String[] args) throws IOException, > MalformedObjectNameException, InstanceNotFoundException, > ReflectionException { > MBeanServerConnection mbeanServerConnection = > getLocalMBeanServerConnectionStatic(127510); > ObjectName mbeanName = new > ObjectName("GemFire:type=Member,member=server1"); > MemberMXBean > memberbeanInstance = > (MemberMXBean) MBeanServerInvocationHandler > .newProxyInstance(mbeanServerConnection, mbeanName, > MemberMXBean.class, Boolean.TRUE); > System.out.println(Arrays.toString(memberbeanInstance.listRegions())); > OSMetrics cdOSMetrics = memberbeanInstance.showOSMetrics(); > //..... > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)