diff --git a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java index 45f2b0e19..1307ce402 100644 --- a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java +++ b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java @@ -52,6 +52,20 @@ public CloseableHttpClient getHttpClient() { .build(); public HttpClientBuilder getHttpClientBuilderForBatch() { - return httpClientBuilder.setDefaultRequestConfig(requestConfig); + return HttpClients.custom() + .setRedirectStrategy( + new DefaultRedirectStrategy() { + @Override + protected boolean isRedirectable(String method) { + return true; + } + }) + .setDefaultRequestConfig(requestConfig); + } + + public HttpClientBuilder getHttpClientBuilderForCopyBatch() { + return HttpClients.custom() + .disableRedirectHandling() + .setDefaultRequestConfig(requestConfig); } } diff --git a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/BatchStageLoad.java b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/BatchStageLoad.java index bd9dcf177..c192d76f4 100644 --- a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/BatchStageLoad.java +++ b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/BatchStageLoad.java @@ -85,8 +85,7 @@ public class BatchStageLoad implements Serializable { private final AtomicBoolean started; private volatile boolean loadThreadAlive = false; private AtomicReference exception = new AtomicReference<>(null); - private HttpClientBuilder httpClientBuilder = - new HttpUtil().getHttpClientBuilderForBatch().disableRedirectHandling(); + private HttpClientBuilder httpClientBuilder = new HttpUtil().getHttpClientBuilderForCopyBatch(); public BatchStageLoad( DorisOptions dorisOptions, diff --git a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/DorisCopyCommitter.java b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/DorisCopyCommitter.java index e746fcf7c..095c680a7 100644 --- a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/DorisCopyCommitter.java +++ b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/copy/DorisCopyCommitter.java @@ -49,7 +49,7 @@ public class DorisCopyCommitter implements Committer, Clos private static final String FAIL = "1"; private ObjectMapper objectMapper = new ObjectMapper(); private final DorisOptions dorisOptions; - private HttpClientBuilder httpClientBuilder = new HttpUtil().getHttpClientBuilderForBatch(); + private HttpClientBuilder httpClientBuilder = new HttpUtil().getHttpClientBuilderForCopyBatch(); int maxRetry; public DorisCopyCommitter(DorisOptions dorisOptions, int maxRetry) {