JNSimba commented on code in PR #79:
URL: 
https://github.com/apache/doris-spark-connector/pull/79#discussion_r1150712679


##########
spark-doris-connector/src/main/java/org/apache/doris/spark/DorisStreamLoad.java:
##########
@@ -247,39 +251,30 @@ private LoadResponse loadBatch(String value) {
                 calendar.get(Calendar.HOUR_OF_DAY), 
calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND),
                 UUID.randomUUID().toString().replaceAll("-", ""));
 
-        String loadUrlStr = String.format(loadUrlPattern, getBackend(), db, 
tbl);
-        LOG.debug("Streamload Request:{} ,Body:{}", loadUrlStr, value);
-        //only to record the BE node in case of an exception
-        this.loadUrlStr = loadUrlStr;
-
-        HttpURLConnection beConn = null;
-        int status = -1;
-        try {
-            // build request and send to new be location
-            beConn = getConnection(loadUrlStr, label);
-            // send data to be
-            try (OutputStream beConnOutputStream = new 
BufferedOutputStream(beConn.getOutputStream())) {
-                IOUtils.write(value, beConnOutputStream, 
StandardCharsets.UTF_8);
-            }
-
-            // get respond
-            status = beConn.getResponseCode();
-            String respMsg = beConn.getResponseMessage();
-            String response;
-            try (InputStream beConnInputStream = beConn.getInputStream()) {
-                response = IOUtils.toString(beConnInputStream, 
StandardCharsets.UTF_8);
+        int responseHttpStatus = -1;
+        try (CloseableHttpClient httpClient = getHttpClient()) {
+            String loadUrlStr = String.format(loadUrlPattern, getBackend(), 
db, tbl);
+            LOG.debug("Streamload Request:{} ,Body:{}", loadUrlStr, value);
+            //only to record the BE node in case of an exception
+            this.loadUrlStr = loadUrlStr;
+
+            HttpPut httpPut = getHttpPut(label, loadUrlStr);
+            httpPut.setEntity(new StringEntity(value, StandardCharsets.UTF_8));
+            HttpResponse httpResponse = httpClient.execute(httpPut);
+            responseHttpStatus = httpResponse.getStatusLine().getStatusCode();
+            String respMsg = httpResponse.getStatusLine().getReasonPhrase();
+            HttpEntity httpEntity = httpResponse.getEntity();
+            if (httpEntity != null) {
+                String response = EntityUtils.toString(new 
BufferedHttpEntity(httpEntity), StandardCharsets.UTF_8);
+                return new LoadResponse(responseHttpStatus, respMsg, response);
+            } else {
+                return new LoadResponse(responseHttpStatus, "", "");

Review Comment:
   Don't need to return `respMsg` here?



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