84
84
import java .util .concurrent .CompletionException ;
85
85
import java .util .concurrent .ConcurrentHashMap ;
86
86
import java .util .concurrent .ExecutionException ;
87
+ import java .util .concurrent .ExecutorService ;
87
88
import java .util .concurrent .TimeUnit ;
88
89
import java .util .logging .Logger ;
89
90
import java .util .stream .Collectors ;
@@ -136,6 +137,7 @@ public abstract class S3Base {
136
137
protected String region ;
137
138
protected Provider provider ;
138
139
protected OkHttpClient httpClient ;
140
+ private final ExecutorService executorService ;
139
141
140
142
protected S3Base (
141
143
HttpUrl baseUrl ,
@@ -145,7 +147,8 @@ protected S3Base(
145
147
boolean useVirtualStyle ,
146
148
String region ,
147
149
Provider provider ,
148
- OkHttpClient httpClient ) {
150
+ OkHttpClient httpClient ,
151
+ ExecutorService executorService ) {
149
152
this .baseUrl = baseUrl ;
150
153
this .awsS3Prefix = awsS3Prefix ;
151
154
this .awsDomainSuffix = awsDomainSuffix ;
@@ -154,6 +157,7 @@ protected S3Base(
154
157
this .region = region ;
155
158
this .provider = provider ;
156
159
this .httpClient = httpClient ;
160
+ this .executorService = executorService ;
157
161
}
158
162
159
163
/** @deprecated This method is no longer supported. */
@@ -167,7 +171,8 @@ protected S3Base(
167
171
boolean isDualStackHost ,
168
172
boolean useVirtualStyle ,
169
173
Provider provider ,
170
- OkHttpClient httpClient ) {
174
+ OkHttpClient httpClient ,
175
+ ExecutorService executorService ) {
171
176
this .baseUrl = baseUrl ;
172
177
if (isAwsHost ) this .awsS3Prefix = "s3." ;
173
178
if (isFipsHost ) this .awsS3Prefix = "s3-fips." ;
@@ -182,6 +187,7 @@ protected S3Base(
182
187
this .region = region ;
183
188
this .provider = provider ;
184
189
this .httpClient = httpClient ;
190
+ this .executorService = executorService ;
185
191
}
186
192
187
193
protected S3Base (S3Base client ) {
@@ -193,6 +199,7 @@ protected S3Base(S3Base client) {
193
199
this .region = client .region ;
194
200
this .provider = client .provider ;
195
201
this .httpClient = client .httpClient ;
202
+ this .executorService = client .executorService ;
196
203
}
197
204
198
205
/** Check whether argument is valid or not. */
@@ -1135,7 +1142,8 @@ protected CompletableFuture<Integer> calculatePartCountAsync(List<ComposeSource>
1135
1142
long [] objectSize = {0 };
1136
1143
int index = 0 ;
1137
1144
1138
- CompletableFuture <Integer > completableFuture = CompletableFuture .supplyAsync (() -> 0 );
1145
+ CompletableFuture <Integer > completableFuture =
1146
+ CompletableFuture .supplyAsync (() -> 0 , executorService );
1139
1147
for (ComposeSource src : sources ) {
1140
1148
index ++;
1141
1149
final int i = index ;
@@ -2854,7 +2862,8 @@ private CompletableFuture<ObjectWriteResponse> putMultipartObjectAsync(
2854
2862
}
2855
2863
}
2856
2864
return response ;
2857
- });
2865
+ },
2866
+ executorService );
2858
2867
}
2859
2868
2860
2869
/**
@@ -2900,7 +2909,8 @@ protected CompletableFuture<ObjectWriteResponse> putObjectAsync(
2900
2909
} catch (NoSuchAlgorithmException | IOException e ) {
2901
2910
throw new CompletionException (e );
2902
2911
}
2903
- })
2912
+ },
2913
+ executorService )
2904
2914
.thenCompose (
2905
2915
partSource -> {
2906
2916
try {
0 commit comments