This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 13ea7e6bb61 Load: Fix InstanceAlreadyExistsException caused by 
concurrent registration on JMXService (#11755)
13ea7e6bb61 is described below

commit 13ea7e6bb6196b5f6f76d97a040060eb722c2e67
Author: Caideyipi <[email protected]>
AuthorDate: Thu Dec 21 01:06:23 2023 +0800

    Load: Fix InstanceAlreadyExistsException caused by concurrent registration 
on JMXService (#11755)
    
    Previously, the concurrent call to "registerMBean" or "deregisterMBean" may 
cause after 2 threads seeing the same state simultaneously, that one thread 
changes the state and make another one throw InstanceAlreadyExistsException or 
InstanceNotFoundException. This PR fixed this problem by adding synchronize to 
the 2 functions.
---
 .../main/java/org/apache/iotdb/commons/service/JMXService.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/JMXService.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/JMXService.java
index 4f0bef1f3e8..e934e953b58 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/JMXService.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/JMXService.java
@@ -41,8 +41,8 @@ public class JMXService implements IService {
     // Empty constructor
   }
 
-  /** function for registering MBean. */
-  public static void registerMBean(Object mbean, String name) {
+  /** Function for registering MBean. */
+  public static synchronized void registerMBean(Object mbean, String name) {
     try {
       MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
       ObjectName objectName = new ObjectName(name);
@@ -57,8 +57,8 @@ public class JMXService implements IService {
     }
   }
 
-  /** function for deregistering MBean. */
-  public static void deregisterMBean(String name) {
+  /** Function for deregistering MBean. */
+  public static synchronized void deregisterMBean(String name) {
     try {
       MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
       ObjectName objectName = new ObjectName(name);

Reply via email to