imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936782282
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
⚠️ Method name `checkPdModeEnabled()` is non-idiomatic for a method that
throws — Java convention uses imperative names like `ensure*` or `require*` for
assertion/guard methods. Consider renaming:
```java
public static void ensurePdModeEnabled(GraphManager manager) {
```
Also missing: a null-check for `manager` and a Javadoc comment explaining
what exception is thrown and when.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
⚠️ Declaring this as `public static` on the widely-used `API` base class
unnecessarily expands the public API surface. Since this guard is only called
from API subclasses, consider reducing visibility to `protected`:
```java
protected static void checkPdModeEnabled(GraphManager manager) {
```
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.usePD()) {
+ throw new HugeException(
+ "GraphSpace management is not supported in standalone
mode");
Review Comment:
🧹 The error message `"GraphSpace management is not supported in standalone
mode"` is duplicated across production code and tests. Extract it to a constant
to avoid typos and make future changes easier:
```java
private static final String PD_MODE_REQUIRED_MSG =
"GraphSpace management is not supported in standalone mode";
```
--
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]