gavinchou commented on code in PR #16340:
URL: https://github.com/apache/doris/pull/16340#discussion_r1111136930


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java:
##########
@@ -197,14 +285,42 @@ protected void realNetSend(ByteBuffer buffer) throws 
IOException {
         isSend = true;
     }
 
+    protected void encryptData(ByteBuffer dstBuf) throws SSLException {
+        if (isSslMode) {
+            ByteBuffer netData = 
ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
+            sslEngine.wrap(dstBuf, netData);
+            netData.flip();
+            dstBuf.clear();
+            dstBuf.put(netData);
+            dstBuf.flip();
+        }
+    }
+
     public void flush() throws IOException {
-        if (null == sendBuffer || sendBuffer.position() == 0) {
+        ByteBuffer sendData ;
+        if(isSslMode|isHandshaking){
+            sendData = sendSslBuffer;

Review Comment:
   Use ternary expression to reduce lines of code, e.g.
   ```
   sendData = x ? a : b;
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlChannel.java:
##########
@@ -197,14 +285,42 @@ protected void realNetSend(ByteBuffer buffer) throws 
IOException {
         isSend = true;
     }
 
+    protected void encryptData(ByteBuffer dstBuf) throws SSLException {
+        if (isSslMode) {
+            ByteBuffer netData = 
ByteBuffer.allocate(sslEngine.getSession().getPacketBufferSize());
+            sslEngine.wrap(dstBuf, netData);
+            netData.flip();
+            dstBuf.clear();
+            dstBuf.put(netData);
+            dstBuf.flip();
+        }
+    }
+
     public void flush() throws IOException {
-        if (null == sendBuffer || sendBuffer.position() == 0) {
+        ByteBuffer sendData ;
+        if(isSslMode|isHandshaking){
+            sendData = sendSslBuffer;

Review Comment:
   Use a ternary expression to reduce lines of code, e.g.
   ```
   sendData = x ? a : b;
   ```



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to