This is an automated email from the ASF dual-hosted git repository. liaoxin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new c5fb4712725 [chore](compile) Fix implicit conversion in stream_load_forward_handler (#55632) c5fb4712725 is described below commit c5fb4712725a9a4576991035bf2d2e2b312f828f Author: Xin Liao <liao...@selectdb.com> AuthorDate: Wed Sep 3 22:15:57 2025 +0800 [chore](compile) Fix implicit conversion in stream_load_forward_handler (#55632) --- be/src/http/action/stream_load_forward_handler.cpp | 17 +++++++++++------ be/src/http/action/stream_load_forward_handler.h | 7 ++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/be/src/http/action/stream_load_forward_handler.cpp b/be/src/http/action/stream_load_forward_handler.cpp index 3f1719312fb..d3d713971ca 100644 --- a/be/src/http/action/stream_load_forward_handler.cpp +++ b/be/src/http/action/stream_load_forward_handler.cpp @@ -29,6 +29,7 @@ #include "util/byte_buffer.h" namespace doris { +#include "common/compile_check_begin.h" int StreamLoadForwardHandler::on_header(HttpRequest* req) { std::ostringstream headers_info; @@ -62,7 +63,7 @@ int StreamLoadForwardHandler::on_header(HttpRequest* req) { } std::string target_host; - int target_port; + uint16_t target_port; Status st = parse_forward_target(it->second, target_host, target_port); if (!st.ok()) { LOG(WARNING) << "StreamLoadForward failed - invalid forward target: " << st.to_string() @@ -172,7 +173,7 @@ void StreamLoadForwardHandler::on_chunk_data(HttpRequest* req) { } Status StreamLoadForwardHandler::init_forward_request( - HttpRequest* req, const std::string& target_host, int target_port, + HttpRequest* req, const std::string& target_host, uint16_t target_port, std::shared_ptr<StreamLoadForwardContext>& ctx) { ctx->original_req = req; @@ -303,7 +304,7 @@ void StreamLoadForwardHandler::forward_connection_close_cb(struct evhttp_connect } Status StreamLoadForwardHandler::parse_forward_target(const std::string& forward_to, - std::string& host, int& port) { + std::string& host, uint16_t& port) { size_t pos = forward_to.find(':'); if (pos == std::string::npos) { return Status::InvalidArgument("Invalid forward_to format, should be host:port, got: {}", @@ -312,18 +313,21 @@ Status StreamLoadForwardHandler::parse_forward_target(const std::string& forward host = forward_to.substr(0, pos); std::string port_str = forward_to.substr(pos + 1); + int parsed_port = 0; try { - port = std::stoi(port_str); + parsed_port = std::stoi(port_str); } catch (const std::exception& e) { LOG(WARNING) << "Exception while parsing port: " << port_str << ", what(): " << e.what(); return Status::InvalidArgument("Invalid port number in forward_to: {}, exception: {}", port_str, e.what()); } - if (port <= 0 || port > 65535) { - return Status::InvalidArgument("Port number must be between 1 and 65535, got: {}", port); + if (parsed_port <= 0 || parsed_port > 65535) { + return Status::InvalidArgument("Port number must be between 1 and 65535, got: {}", + parsed_port); } + port = static_cast<uint16_t>(parsed_port); return Status::OK(); } @@ -394,4 +398,5 @@ void StreamLoadForwardHandler::setup_forward_headers(HttpRequest* req, evhttp_request_get_host(req->get_evhttp_request())); } +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/http/action/stream_load_forward_handler.h b/be/src/http/action/stream_load_forward_handler.h index c5c7c674ddc..2d5e6a32b95 100644 --- a/be/src/http/action/stream_load_forward_handler.h +++ b/be/src/http/action/stream_load_forward_handler.h @@ -81,7 +81,7 @@ public: HttpRequest* original_req {nullptr}; std::string target_host; - int target_port {0}; + uint16_t target_port {0}; // Buffer for collecting response data std::string response_data; @@ -112,7 +112,8 @@ public: void on_chunk_data(HttpRequest* req) override; private: - Status init_forward_request(HttpRequest* req, const std::string& target_host, int target_port, + Status init_forward_request(HttpRequest* req, const std::string& target_host, + uint16_t target_port, std::shared_ptr<StreamLoadForwardContext>& ctx); static void forward_request_done(struct evhttp_request* req, void* arg); @@ -125,7 +126,7 @@ private: static void copy_response_headers(struct evkeyvalq* input_headers, struct evkeyvalq* output_headers); - Status parse_forward_target(const std::string& forward_to, std::string& host, int& port); + Status parse_forward_target(const std::string& forward_to, std::string& host, uint16_t& port); std::string build_forward_url(HttpRequest* req); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org