SbloodyS commented on code in PR #17694:
URL: 
https://github.com/apache/dolphinscheduler/pull/17694#discussion_r2558383006


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OkHttpUtils.java:
##########
@@ -68,6 +72,59 @@ public class OkHttpUtils {
         }
     }
 
+    /**
+     * Executes a synchronous GET request and returns both the {@link Call} 
object (for cancellation support)
+     * and the HTTP response.
+     *
+     * <p>This method enables the caller to retain a reference to the 
underlying OkHttp {@link Call},
+     * allowing the request to be canceled from another thread (e.g., during 
task interruption).
+     * Although the execution is blocking, calling {@link Call#cancel()} 
concurrently will cause
+     * {@link Call#execute()} to throw an {@link IOException} with the message 
"canceled".
+     *
+     * @param url                the target URL for the GET request (must not 
be null)
+     * @param okHttpRequestHeaders optional HTTP headers; may be null
+     * @param requestParams      query parameters to be appended to the URL as 
key-value pairs; may be null
+     * @param connectTimeout     connection timeout in milliseconds
+     * @param writeTimeout       write (send) timeout in milliseconds
+     * @param readTimeout        read (receive) timeout in milliseconds
+     * @return                   a wrapper containing the {@link Call} and the 
resulting {@link OkHttpResponse}
+     * @throws IOException       if a network error occurs or the request is 
canceled during execution
+     * @throws RuntimeException  if an unexpected error occurs during request 
processing
+     */
+    public static @NonNull OkHttpResult getWithCall(

Review Comment:
   The current `get` method has implemented the `AutoCloseable` interface, and 
its connection is secure, so it doesn't need to be closed again.



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

Reply via email to