imbajin commented on code in PR #685:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/685#discussion_r2465621188
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -198,51 +198,85 @@ public Map<String, String> reload() {
}
public void mode(String graph, GraphMode mode) {
- // NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
- // be encoded to "%2F". So use "mode" here, although inaccurate.
- this.client.put(joinPath(this.path(), graph, MODE), null, mode);
+ mode(null, graph, mode);
}
- public GraphMode mode(String graph) {
- RestResult result = this.client.get(joinPath(this.path(), graph),
MODE);
- @SuppressWarnings("unchecked")
- Map<String, String> mode = result.readObject(Map.class);
- String value = mode.get(MODE);
- if (value == null) {
- throw new InvalidResponseException("Invalid response, expect
'mode' in response");
- }
- try {
- return GraphMode.valueOf(value);
- } catch (IllegalArgumentException e) {
- throw new InvalidResponseException("Invalid GraphMode value '%s'",
value);
+ public void mode(String graphSpace, String graph, GraphMode mode) {
+ // NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
+ // be encoded to "%2F". So use "mode" here, although inaccurate.
+ if (graphSpace == null) {
+ this.client.put(joinPath(this.path(), graph, MODE), null, mode);
+ return;
}
+ this.client.put(joinPath(this.path(), graphSpace, graph, MODE), null,
mode);
}
public void readMode(String graph, GraphReadMode readMode) {
+ readMode(null, graph, readMode);
+ }
+
+
+ public void readMode(String graphSpace, String graph, GraphReadMode
readMode) {
this.client.checkApiVersion("0.59", "graph read mode");
// NOTE: Must provide id for PUT. If you use "graph/graph_read_mode",
"/"
// will be encoded to "%2F". So use "graph_read_mode" here, although
// inaccurate.
- this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null,
readMode);
+ if (graphSpace == null) {
+ this.client.put(joinPath(this.path(), graph, MODE), null,
readMode);
+ return;
Review Comment:
‼️ **代码逻辑错误**
这里应该使用 `GRAPH_READ_MODE` 而不是 `MODE`。当 `graphSpace` 为 null 时,这个方法会错误地设置 graph
mode 而不是 read mode。
**建议修改:**
```java
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null,
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]