Copilot commented on code in PR #2912:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2912#discussion_r2659464159


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java:
##########
@@ -953,6 +954,14 @@ public void updateTime(Date updateTime) {
         this.hugegraph.updateTime(updateTime);
     }
 
+    public static String username() {
+        Context context = HugeGraphAuthProxy.getContext();
+        if (context == null) {
+            return "anonymous";
+        }
+        return context.user.username();
+    }

Review Comment:
   The `username()` method should be placed near other static utility methods 
(lines 155-204) rather than in the middle of instance methods. This improves 
code organization and makes it easier to locate static methods. Consider moving 
this method to be placed after the `getContext()` method around line 196, which 
it depends on.



##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java:
##########
@@ -953,6 +954,14 @@ public void updateTime(Date updateTime) {
         this.hugegraph.updateTime(updateTime);
     }
 
+    public static String username() {
+        Context context = HugeGraphAuthProxy.getContext();
+        if (context == null) {
+            return "anonymous";
+        }
+        return context.user.username();

Review Comment:
   Direct field access `context.user` is inconsistent with the rest of the 
codebase. The Context class provides a public `user()` method that should be 
used instead. All other usages in the codebase access the user through the 
method call `context.user()` (e.g., lines 203, 1171, 1172, 1202, 1458, 1489). 
Change `context.user.username()` to `context.user().username()` to maintain 
consistency.



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