nastra commented on code in PR #8032:
URL: https://github.com/apache/iceberg/pull/8032#discussion_r1288664327
##########
core/src/main/java/org/apache/iceberg/rest/HTTPClient.java:
##########
@@ -71,31 +74,73 @@ public class HTTPClient implements RESTClient {
static final String CLIENT_GIT_COMMIT_SHORT_HEADER =
"X-Client-Git-Commit-Short";
private final String uri;
- private final CloseableHttpClient httpClient;
- private final ObjectMapper mapper;
+ private final SerializableMap<String, String> baseHeaders;
+ private final SerializableMap<String, String> properties;
+ private transient volatile CloseableHttpClient httpClient;
+ private transient volatile ObjectMapper mapper;
private HTTPClient(
String uri,
- Map<String, String> baseHeaders,
- ObjectMapper objectMapper,
- HttpRequestInterceptor requestInterceptor) {
+ SerializableMap<String, String> baseHeaders,
+ SerializableMap<String, String> properties,
+ ObjectMapper mapper) {
this.uri = uri;
- this.mapper = objectMapper;
+ this.baseHeaders = baseHeaders;
+ this.properties = properties;
+ this.mapper = mapper;
+ }
+
+ private CloseableHttpClient httpClient() {
+ if (null == httpClient) {
+ synchronized (this) {
+ if (null == httpClient) {
+ HttpClientBuilder clientBuilder = HttpClients.custom();
+
+ if (baseHeaders != null) {
+ clientBuilder.setDefaultHeaders(
+ baseHeaders.entrySet().stream()
+ .map(e -> new BasicHeader(e.getKey(), e.getValue()))
+ .collect(Collectors.toList()));
+ }
+
+ if (PropertyUtil.propertyAsBoolean(properties, SIGV4_ENABLED,
false)) {
+ clientBuilder.addRequestInterceptorLast(
+ loadInterceptorDynamically(SIGV4_REQUEST_INTERCEPTOR_IMPL,
properties));
+ }
+
+ httpClient = clientBuilder.build();
+ }
+ }
+ }
- HttpClientBuilder clientBuilder = HttpClients.custom();
+ return httpClient;
+ }
- if (baseHeaders != null) {
- clientBuilder.setDefaultHeaders(
- baseHeaders.entrySet().stream()
- .map(e -> new BasicHeader(e.getKey(), e.getValue()))
- .collect(Collectors.toList()));
+ private ObjectMapper mapper() {
+ if (null == mapper) {
+ synchronized (this) {
+ if (null == mapper) {
+ mapper =
loadObjectMapperDynamically(properties.getOrDefault(OBJECT_MAPPER_IMPL, null));
Review Comment:
I've moved away from dynamically loading this and instead went with
https://github.com/apache/iceberg/pull/8032#discussion_r1259383997
--
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]