You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/12/11 10:39:48 UTC

[GitHub] [incubator-eventmesh] walterlife commented on a diff in pull request #2553: [Enhancement] Method invocation 'getBytes' may produce 'NullPointerException' [HttpCommand]

walterlife commented on code in PR #2553:
URL: https://github.com/apache/incubator-eventmesh/pull/2553#discussion_r1045209946


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java:
##########
@@ -110,132 +114,62 @@ public HttpCommand createHttpCommandResponse(EventMeshRetCode eventMeshRetCode)
         return response;
     }
 
-    public long getReqTime() {
-        return reqTime;
-    }
-
-    public void setReqTime(long reqTime) {
-        this.reqTime = reqTime;
-    }
-
-    public long getResTime() {
-        return resTime;
-    }
-
-    public void setResTime(long resTime) {
-        this.resTime = resTime;
-    }
-
-    public long getOpaque() {
-        return opaque;
-    }
-
-    public void setOpaque(long opaque) {
-        this.opaque = opaque;
-    }
-
-    public CmdType getCmdType() {
-        return cmdType;
-    }
-
-    public void setCmdType(CmdType cmdType) {
-        this.cmdType = cmdType;
-    }
-
-    public String getHttpMethod() {
-        return httpMethod;
-    }
-
-    public void setHttpMethod(String httpMethod) {
-        this.httpMethod = httpMethod;
-    }
-
-    public String getHttpVersion() {
-        return httpVersion;
-    }
-
-    public void setHttpVersion(String httpVersion) {
-        this.httpVersion = httpVersion;
-    }
-
-    public String getRequestCode() {
-        return requestCode;
-    }
-
-    public void setRequestCode(String requestCode) {
-        this.requestCode = requestCode;
-    }
-
-    public Header getHeader() {
-        return header;
-    }
-
-    public void setHeader(Header header) {
-        this.header = header;
-    }
-
-    public Body getBody() {
-        return body;
-    }
-
-    public void setBody(Body body) {
-        this.body = body;
-    }
-
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("httpCommand={")
-                .append(cmdType).append(",")
-                .append(httpMethod).append("/").append(httpVersion).append(",")
-                .append("requestCode=").append(requestCode).append(",")
-                .append("opaque=").append(opaque).append(",");
+            .append(cmdType).append(",")
+            .append(httpMethod).append("/").append(httpVersion).append(",")
+            .append("requestCode=").append(requestCode).append(",")
+            .append("opaque=").append(opaque).append(",");
 
         if (cmdType == CmdType.RES) {
             sb.append("cost=").append(resTime - reqTime).append(",");
         }
 
         sb.append("header=").append(header).append(",")
-                .append("body=").append(body)
-                .append("}");
+            .append("body=").append(body)
+            .append("}");
 
         return sb.toString();
     }
 
     public String abstractDesc() {
         StringBuilder sb = new StringBuilder();
         sb.append("httpCommand={")
-                .append(cmdType).append(",")
-                .append(httpMethod).append("/").append(httpVersion).append(",")
-                .append("requestCode=").append(requestCode).append(",")
-                .append("opaque=").append(opaque).append(",");
+            .append(cmdType).append(",")
+            .append(httpMethod).append("/").append(httpVersion).append(",")
+            .append("requestCode=").append(requestCode).append(",")
+            .append("opaque=").append(opaque).append(",");
 
         if (cmdType == CmdType.RES) {
             sb.append("cost=").append(resTime - reqTime).append(",");
         }
 
         sb.append("header=").append(header).append(",")
-                .append("bodySize=").append(body.toString().length()).append("}");
+            .append("bodySize=").append(body.toString().length()).append("}");
 
         return sb.toString();
     }
 
     public String simpleDesc() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("httpCommand={")
-                .append(cmdType).append(",")
-                .append(httpMethod).append("/").append(httpVersion).append(",")
-                .append("requestCode=").append(requestCode).append("}");
-
-        return sb.toString();
+        return "httpCommand={"
+            + cmdType
+            + ","
+            + httpMethod
+            + "/" + httpVersion
+            + ","
+            + "requestCode="
+            + requestCode
+            + "}";

Review Comment:
   It is recommended to use StringBuilder uniformly here to ensure the consistency of the internal code of the class as much as possible.



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org