imbajin commented on code in PR #2900:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2900#discussion_r2489653528


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -1227,10 +1228,42 @@ private void dropGraphLocal(HugeGraph graph) {
     public HugeGraph createGraph(String graphSpace, String name, String 
creator,
                                  Map<String, Object> configs, boolean init) {
         if (!usePD()) {
-            return createGraphLocal(configs.toString(), name);
+            // Extract nickname from configs
+            String nickname;
+            if (configs.get("nickname") != null) {
+                nickname = configs.get("nickname").toString();

Review Comment:
   ‼️ **Critical: 参数处理逻辑错误**
   
   在 `createGraph` 方法中,nickname 从 configs 中提取后没有被移除。这会导致 nickname 被同时设置两次:
   1. 在 Properties 配置中(通过 propConfig.setProperty)
   2. 在返回的 graph 对象上(通过 graph.nickname(nickname))
   
   建议在提取 nickname 后将其从 configs 中移除,避免重复设置。



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -1227,10 +1228,42 @@ private void dropGraphLocal(HugeGraph graph) {
     public HugeGraph createGraph(String graphSpace, String name, String 
creator,
                                  Map<String, Object> configs, boolean init) {
         if (!usePD()) {
-            return createGraphLocal(configs.toString(), name);
+            // Extract nickname from configs
+            String nickname;
+            if (configs.get("nickname") != null) {
+                nickname = configs.get("nickname").toString();
+                checkNickname(nickname);
+            } else {
+                nickname = name;
+            }
+
+            Date timeStamp = new Date();
+
+            // Convert Map to Properties format string
+            PropertiesConfiguration propConfig = new PropertiesConfiguration();
+            for (Map.Entry<String, Object> entry : configs.entrySet()) {
+                propConfig.setProperty(entry.getKey(), entry.getValue());
+            }
+            StringWriter writer = new StringWriter();
+            try {
+                propConfig.write(writer);

Review Comment:
   ⚠️ **Important: 异常处理不够具体**
   
   catch 块捕获了所有 Exception,这会掩盖具体的错误信息。建议分别处理 ConfigurationException 和 
IOException,提供更明确的错误信息。



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -1931,7 +1964,7 @@ public HugeGraph graph(String graphSpace, String name) {
     }
 
     public void dropGraphLocal(String name) {
-        HugeGraph graph = this.graph(name);
+        HugeGraph graph = this.graph(DEFAULT_GRAPH_SPACE_SERVICE_NAME + "-" + 
name);

Review Comment:
   ⚠️ **Important: 硬编码的字符串分隔符**
   
   使用硬编码的 \"-\" 作为分隔符,但代码中其他地方使用了 DELIMITER 常量。建议保持一致性使用 DELIMITER 常量。



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -2107,6 +2151,12 @@ private MapConfiguration buildConfig(Map<String, Object> 
configs) {
 
     public void graphReadMode(String graphSpace, String graphName,
                               GraphReadMode readMode) {
+
+        if (!usePD()) {

Review Comment:
   ⚠️ **Important: graphReadMode 方法逻辑不完整**
   
   在非 PD 模式下设置了 readMode,但之后仍然尝试执行 PD 
相关的逻辑(`this.metaManager.getGraphConfig`)。这可能会导致错误。建议在非 PD 模式下设置 readMode 后直接返回。



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to