You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/12/14 15:11:53 UTC

[GitHub] [incubator-eventmesh] eight-nines commented on a diff in pull request #2586: Improve the configuration management code framework

eight-nines commented on code in PR #2586:
URL: https://github.com/apache/incubator-eventmesh/pull/2586#discussion_r1048593388


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/Convert.java:
##########
@@ -198,120 +187,127 @@ private void setValue() throws Exception {
                 }
                 field.set(object, value);
             }
+
+            if (!needReload) return;
+            Method method = this.clazz.getDeclaredMethod("reload", null);
+            method.setAccessible(true);
+            method.invoke(this.object, null);
         }
 
         public String getKey(String fieldName, char spot) {
-            StringBuffer key = new StringBuffer(Objects.isNull(prefix) ? "" : prefix);
+            StringBuilder key = new StringBuilder(Objects.isNull(prefix) ? "" : prefix);
 
             boolean currency = false;
-            for (int i = 0; i < fieldName.length(); i++) {
+            int length = fieldName.length();
+            for (int i = 0; i < length; i++) {
                 char c = fieldName.charAt(i);
+                boolean b = i < length - 1 && fieldName.charAt(i + 1) > 96;
+
                 if (currency) {
-                    if (fieldName.length() > (i + 1) && fieldName.charAt(i + 1) > 96) {
+                    if (b) {
                         key.append(spot);
                         key.append((char) (c + 32));
                         currency = false;
                     } else {
                         key.append(c);
                     }
-                    key.append(c);
                 } else {
                     if (c > 96) {
                         key.append(c);
                     } else {
                         key.append(spot);
-                        if (fieldName.length() > (i + 1) && fieldName.charAt(i + 1) > 96) {
+                        if (b) {
                             key.append((char) (c + 32));
                         } else {
                             key.append(c);
                             currency = true;
                         }
-
                     }
                 }
             }
-            return key.toString();
+            if (fieldName.startsWith("eventMesh")) {
+                key.replace(0, 10, "eventMesh");

Review Comment:
   只是 clazz 的话,当时没有考虑到 prefix 的场景,新版本考虑两个注解联动,已修改



-- 
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