Skip to content

Commit

Permalink
use string.format and comment corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
Amila-Rukshan committed Oct 21, 2022
1 parent 6e33a8b commit 0ffeff4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public static void initJMXAgent() {

LocateRegistry.createRegistry(Integer.parseInt(rmiRegistryPort));

String jmxURL = "service:jmx:rmi://" + hostname + ":" + rmiServerPort
+ "/jndi/rmi://" + hostname + ":" + rmiRegistryPort + "/jmxrmi";
String jmxURL = String.format("service:jmx:rmi://%s:%s/jndi/rmi://%s:%s/jmxrmi", hostname,
rmiServerPort,
hostname, rmiRegistryPort);
JMXServiceURL jmxServiceURL = new JMXServiceURL(jmxURL);

jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
public class MBeanManagementFactory {

/*
* @return A MBeanServer instance.
* If one already exists, it will return that else it will create a new one and
* return.
*
* @return A MBeanServer instance.
*/
public static MBeanServer getMBeanServer() {
MBeanServer mBeanServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void registerMBean(Object mBeanInstance) throws RuntimeException {
className = className.substring(className.lastIndexOf('.') + 1);
}

String objectName = SERVER_PACKAGE + ":type=" + className;
String objectName = String.format("%s:type=%s", SERVER_PACKAGE, className);
try {
MBeanServer mBeanServer = MBeanManagementFactory.getMBeanServer();
Set set = mBeanServer.queryNames(new ObjectName(objectName), null);
Expand Down

0 comments on commit 0ffeff4

Please sign in to comment.