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 08:55:31 UTC

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

githublaohu commented on code in PR #2586:
URL: https://github.com/apache/incubator-eventmesh/pull/2586#discussion_r1048175297


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/Convert.java:
##########
@@ -362,26 +358,29 @@ public boolean isNotHandleNullValue() {
         @Override
         public List<Object> convert(ConvertInfo convertInfo) {
             try {
-                String key = convertInfo.getKey() + "[";
+                if (convertInfo.getValue() == null) {
+                    return new ArrayList<>();
+                }
+                List<String> values = Splitter.on(",").omitEmptyStrings()

Review Comment:
   这个性能有点差,还有是如果是对象,怎么办?



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/Convert.java:
##########
@@ -426,15 +425,26 @@ public Map<String, Object> convert(ConvertInfo convertInfo) {
         }
     }
 
+    private static class ConvertIPAddress implements ConvertValue<IPAddress> {

Review Comment:
   是否有其他更加优雅的办法



##########
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:
   这个没有实际意义吧,已经有去掉前缀的功能



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