You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/02/10 07:28:41 UTC

[GitHub] [incubator-eventmesh] mxsm commented on a diff in pull request #3073: [ISSUE #3072]Optimize the ConfigMonitorService#load method

mxsm commented on code in PR #3073:
URL: https://github.com/apache/incubator-eventmesh/pull/3073#discussion_r1102376299


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigMonitorService.java:
##########
@@ -52,20 +52,16 @@ public void load() {
                 if (configInfo.getObject().equals(object)) {
                     continue;
                 }
-
                 Field field = configInfo.getObjectField();
-                boolean isAccessible = field.isAccessible();
-                try {
-                    field.setAccessible(true);
-                    field.set(configInfo.getInstance(), object);
-                } finally {
-                    field.setAccessible(isAccessible);
-                }
+                field.setAccessible(true);
+                field.set(configInfo.getInstance(), object);
 
                 configInfo.setObject(object);
                 log.info("config reload success: {}", object);
             } catch (Exception e) {
                 log.error("config reload failed", e);
+            } finally {
+                configInfo.getObjectField().setAccessible(false);

Review Comment:
   > The value of the property before the object was modified cannot be obtained here;Also, the value of the previous property is not necessarily false;What do you think?
   
   Hi @eight-nines Here is the Java method description
   
   ![image](https://user-images.githubusercontent.com/15797831/218028626-250a9280-71ec-48bb-aed8-00b3a566cac1.png)
   if there is a security manager, its checkPermission method is called with a ReflectPermission("suppressAccessChecks") permission. Instead of saying that the property becomes public when it's private.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org