Skip to content

Commit 1433877

Browse files
committed
fix
1 parent b32b8e2 commit 1433877

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

paimon-api/src/main/java/org/apache/paimon/rest/HttpClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import static okhttp3.ConnectionSpec.MODERN_TLS;
4848
import static org.apache.paimon.rest.LoggingInterceptor.DEFAULT_REQUEST_ID;
4949
import static org.apache.paimon.rest.LoggingInterceptor.REQUEST_ID_KEY;
50+
import static org.apache.paimon.rest.RESTObjectMapper.OBJECT_MAPPER;
5051

5152
/** HTTP client for REST catalog. */
5253
public class HttpClient implements RESTClient {
@@ -124,7 +125,7 @@ public <T extends RESTResponse> T post(
124125
Class<T> responseType,
125126
RESTAuthFunction restAuthFunction) {
126127
try {
127-
String bodyStr = RESTObjectMapper.OBJECT_MAPPER.writeValueAsString(body);
128+
String bodyStr = OBJECT_MAPPER.writeValueAsString(body);
128129
Map<String, String> authHeaders = getHeaders(path, "POST", bodyStr, restAuthFunction);
129130
RequestBody requestBody = buildRequestBody(bodyStr);
130131
Request request =
@@ -155,7 +156,7 @@ public <T extends RESTResponse> T delete(String path, RESTAuthFunction restAuthF
155156
public <T extends RESTResponse> T delete(
156157
String path, RESTRequest body, RESTAuthFunction restAuthFunction) {
157158
try {
158-
String bodyStr = RESTObjectMapper.OBJECT_MAPPER.writeValueAsString(body);
159+
String bodyStr = OBJECT_MAPPER.writeValueAsString(body);
159160
Map<String, String> authHeaders = getHeaders(path, "DELETE", bodyStr, restAuthFunction);
160161
RequestBody requestBody = buildRequestBody(bodyStr);
161162
Request request =
@@ -189,9 +190,7 @@ private <T extends RESTResponse> T exec(Request request, Class<T> responseType)
189190
if (!response.isSuccessful()) {
190191
ErrorResponse error;
191192
try {
192-
error =
193-
RESTObjectMapper.OBJECT_MAPPER.readValue(
194-
responseBodyStr, ErrorResponse.class);
193+
error = OBJECT_MAPPER.readValue(responseBodyStr, ErrorResponse.class);
195194
} catch (JsonProcessingException e) {
196195
error =
197196
new ErrorResponse(
@@ -206,7 +205,7 @@ private <T extends RESTResponse> T exec(Request request, Class<T> responseType)
206205
errorHandler.accept(error, requestId);
207206
}
208207
if (responseType != null && responseBodyStr != null) {
209-
return RESTObjectMapper.OBJECT_MAPPER.readValue(responseBodyStr, responseType);
208+
return OBJECT_MAPPER.readValue(responseBodyStr, responseType);
210209
} else if (responseType == null) {
211210
return null;
212211
} else {

paimon-api/src/main/java/org/apache/paimon/rest/auth/DLFAuthProviderFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.util.regex.Matcher;
2525
import java.util.regex.Pattern;
2626

27+
import static org.apache.paimon.rest.RESTCatalogOptions.URI;
28+
2729
/** Factory for {@link DLFAuthProvider}. */
2830
public class DLFAuthProviderFactory implements AuthProviderFactory {
2931

@@ -36,7 +38,7 @@ public String identifier() {
3638
public AuthProvider create(Options options) {
3739
String region =
3840
options.getOptional(RESTCatalogOptions.DLF_REGION)
39-
.orElseGet(() -> parseRegionFromUri(options.get(RESTCatalogOptions.URI)));
41+
.orElseGet(() -> parseRegionFromUri(options.get(URI)));
4042
if (options.getOptional(RESTCatalogOptions.DLF_TOKEN_LOADER).isPresent()) {
4143
DLFTokenLoader dlfTokenLoader =
4244
DLFTokenLoaderFactory.createDLFTokenLoader(

paimon-api/src/main/java/org/apache/paimon/utils/ThreadPoolUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import java.util.function.Consumer;
4545
import java.util.function.Function;
4646

47+
import static org.apache.paimon.utils.ThreadUtils.newDaemonThreadFactory;
48+
4749
/** Utils for thread pool. */
4850
public class ThreadPoolUtils {
4951

@@ -71,15 +73,14 @@ public static ThreadPoolExecutor createCachedThreadPool(
7173
1,
7274
TimeUnit.MINUTES,
7375
workQueue,
74-
ThreadUtils.newDaemonThreadFactory(namePrefix));
76+
newDaemonThreadFactory(namePrefix));
7577
executor.allowCoreThreadTimeOut(true);
7678
return executor;
7779
}
7880

7981
public static ScheduledExecutorService createScheduledThreadPool(
8082
int threadNum, String namePrefix) {
81-
return new ScheduledThreadPoolExecutor(
82-
threadNum, ThreadUtils.newDaemonThreadFactory(namePrefix));
83+
return new ScheduledThreadPoolExecutor(threadNum, newDaemonThreadFactory(namePrefix));
8384
}
8485

8586
/** This method aims to parallel process tasks with memory control and sequentially. */

paimon-core/pom.xml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,8 @@ under the License.
6363
<scope>provided</scope>
6464
</dependency>
6565

66-
<!-- test dependencies -->
6766

68-
<dependency>
69-
<groupId>org.apache.paimon</groupId>
70-
<artifactId>paimon-api</artifactId>
71-
<version>${project.version}</version>
72-
<type>test-jar</type>
73-
<scope>test</scope>
74-
</dependency>
75-
76-
<dependency>
77-
<groupId>com.squareup.okhttp3</groupId>
78-
<artifactId>mockwebserver</artifactId>
79-
<version>${okhttp.version}</version>
80-
<scope>test</scope>
81-
</dependency>
67+
<!-- test dependencies -->
8268

8369
<dependency>
8470
<groupId>org.apache.paimon</groupId>
@@ -225,6 +211,12 @@ under the License.
225211
</exclusions>
226212
</dependency>
227213

214+
<dependency>
215+
<groupId>com.squareup.okhttp3</groupId>
216+
<artifactId>mockwebserver</artifactId>
217+
<version>${okhttp.version}</version>
218+
<scope>test</scope>
219+
</dependency>
228220
<dependency>
229221
<groupId>org.mockito</groupId>
230222
<artifactId>mockito-core</artifactId>

0 commit comments

Comments
 (0)