You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by GitBox <gi...@apache.org> on 2022/04/24 13:18:50 UTC

[GitHub] [incubator-hugegraph] imbajin commented on a diff in pull request #1845: fix hugegraph-api code checkstyle

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


##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java:
##########
@@ -155,7 +151,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
         private void sendError(ChannelHandlerContext ctx, Object msg) {
             // Close the connection as soon as the error message is sent.
             ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED))
-               .addListener(ChannelFutureListener.CLOSE);
+                .addListener(ChannelFutureListener.CLOSE);

Review Comment:
   maybe we should keep the origin align?



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java:
##########
@@ -45,6 +27,23 @@
 import io.netty.handler.codec.http.FullHttpMessage;
 import io.netty.handler.codec.http.HttpMessage;
 import io.netty.util.ReferenceCountUtil;
+import org.apache.tinkerpop.gremlin.server.Settings;
+import org.apache.tinkerpop.gremlin.server.auth.AuthenticationException;
+import org.apache.tinkerpop.gremlin.server.auth.Authenticator;
+import org.apache.tinkerpop.gremlin.server.handler.AbstractAuthenticationHandler;
+import org.apache.tinkerpop.gremlin.server.handler.SaslAuthenticationHandler;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+
+import static io.netty.handler.codec.http.HttpHeaderNames.CONNECTION;
+import static io.netty.handler.codec.http.HttpHeaderNames.UPGRADE;
+import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED;
+import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
+import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD;
+import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME;

Review Comment:
   so as these import rules, u could refer the [style file](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-style.xml) in root dir to improve them



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java:
##########
@@ -1757,7 +1731,7 @@ public static class ContextThreadPoolExecutor extends ThreadPoolExecutor {
         public ContextThreadPoolExecutor(int corePoolSize, int maxPoolSize,
                                          ThreadFactory threadFactory) {
             super(corePoolSize, maxPoolSize, 0L, TimeUnit.MILLISECONDS,
-                  new LinkedBlockingQueue<Runnable>(), threadFactory);
+                    new LinkedBlockingQueue<>(), threadFactory);

Review Comment:
   keep the origin align~



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/WsAndHttpBasicAuthHandler.java:
##########
@@ -114,19 +113,16 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
                     sendError(ctx, msg);
                     return;
                 }
-                byte[] userPass = null;
+                byte[] userPass;
                 try {
                     final String encoded = header.substring(basic.length());
                     userPass = this.decoder.decode(encoded);
-                } catch (IndexOutOfBoundsException iae) {
-                    sendError(ctx, msg);
-                    return;
-                } catch (IllegalArgumentException iae) {
+                } catch (IndexOutOfBoundsException | IllegalArgumentException iae) {
                     sendError(ctx, msg);
                     return;
                 }
                 String authorization = new String(userPass,
-                                                  Charset.forName("UTF-8"));
+                        StandardCharsets.UTF_8);

Review Comment:
   we use the `hugegraph-style` in the wiki (not java original style)
   
   align the param with the highly priority



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/StandardAuthenticator.java:
##########
@@ -95,7 +99,7 @@ private String inputPassword() {
             if (!password.isEmpty()) {
                 return password;
             }
-            System.out.println(notEmptyPrompt);
+            LOG.info(notEmptyPrompt);

Review Comment:
   seems it was not print in the log file (print on the console is right?) @javeme 



-- 
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@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org