This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 63d95bcd18 [rest] Fix auth header generation order in HttpClient
(#7137)
63d95bcd18 is described below
commit 63d95bcd18782b2b5a4936d3ec62601fb271fcb6
Author: Dapeng Sun(孙大鹏) <[email protected]>
AuthorDate: Wed Jan 28 19:01:16 2026 +0800
[rest] Fix auth header generation order in HttpClient (#7137)
---
.../java/org/apache/paimon/rest/HttpClient.java | 38 ++++++++--------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/HttpClient.java
b/paimon-api/src/main/java/org/apache/paimon/rest/HttpClient.java
index b09d3b4528..c59d642e79 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/HttpClient.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/HttpClient.java
@@ -89,19 +89,14 @@ public class HttpClient implements RESTClient {
RESTRequest body,
Class<T> responseType,
RESTAuthFunction restAuthFunction) {
- try {
- String bodyStr = RESTApi.toJson(body);
- Header[] authHeaders = getHeaders(path, "POST", bodyStr,
restAuthFunction);
- HttpPost httpPost = new HttpPost(getRequestUrl(path, null));
- httpPost.setHeaders(authHeaders);
- String encodedBody = RESTUtil.encodedBody(body);
- if (encodedBody != null) {
- httpPost.setEntity(new StringEntity(encodedBody));
- }
- return exec(httpPost, responseType);
- } catch (JsonProcessingException e) {
- throw new RESTException(e, "build post request failed.");
+ HttpPost httpPost = new HttpPost(getRequestUrl(path, null));
+ String encodedBody = RESTUtil.encodedBody(body);
+ if (encodedBody != null) {
+ httpPost.setEntity(new StringEntity(encodedBody));
}
+ Header[] authHeaders = getHeaders(path, "POST", encodedBody,
restAuthFunction);
+ httpPost.setHeaders(authHeaders);
+ return exec(httpPost, responseType);
}
@Override
@@ -112,19 +107,14 @@ public class HttpClient implements RESTClient {
@Override
public <T extends RESTResponse> T delete(
String path, RESTRequest body, RESTAuthFunction restAuthFunction) {
- try {
- String bodyStr = RESTApi.toJson(body);
- Header[] authHeaders = getHeaders(path, "DELETE", bodyStr,
restAuthFunction);
- HttpDelete httpDelete = new HttpDelete(getRequestUrl(path, null));
- httpDelete.setHeaders(authHeaders);
- String encodedBody = RESTUtil.encodedBody(body);
- if (encodedBody != null) {
- httpDelete.setEntity(new StringEntity(encodedBody));
- }
- return exec(httpDelete, null);
- } catch (JsonProcessingException e) {
- throw new RESTException(e, "build delete request failed.");
+ HttpDelete httpDelete = new HttpDelete(getRequestUrl(path, null));
+ String encodedBody = RESTUtil.encodedBody(body);
+ if (encodedBody != null) {
+ httpDelete.setEntity(new StringEntity(encodedBody));
}
+ Header[] authHeaders = getHeaders(path, "DELETE", encodedBody,
restAuthFunction);
+ httpDelete.setHeaders(authHeaders);
+ return exec(httpDelete, null);
}
@VisibleForTesting