Skip to content

Commit 4bcdd9a

Browse files
authored
asynchronously shutdown to decrease delay. (#85)
1 parent 07f0ee6 commit 4bcdd9a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

local-s3-interationtest/src/test/java/com/robothy/s3/test/MultiLocalS3InstanceIntegrationTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.robothy.s3.test;
22

33
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4+
5+
import com.amazonaws.auth.AWSStaticCredentialsProvider;
6+
import com.amazonaws.auth.BasicAWSCredentials;
47
import com.amazonaws.client.builder.AwsClientBuilder;
58
import com.amazonaws.services.s3.AmazonS3;
69
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
710
import com.amazonaws.services.s3.model.HeadBucketRequest;
8-
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
911
import com.robothy.s3.rest.LocalS3;
1012
import com.robothy.s3.rest.bootstrap.LocalS3Mode;
1113
import java.io.IOException;
@@ -55,6 +57,7 @@ void test() throws IOException {
5557
AmazonS3 createClient(int port) {
5658
return AmazonS3ClientBuilder.standard().withEndpointConfiguration(
5759
new AwsClientBuilder.EndpointConfiguration("http://localhost:" + port, "local"))
60+
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("foo", "bar")))
5861
.enablePathStyleAccess()
5962
.build();
6063
}

local-s3-jupiter/src/main/java/com/robothy/s3/jupiter/extensions/AmazonS3Resolver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.robothy.s3.jupiter.extensions;
22

33
import com.amazonaws.ClientConfiguration;
4+
import com.amazonaws.auth.AWSStaticCredentialsProvider;
5+
import com.amazonaws.auth.BasicAWSCredentials;
46
import com.amazonaws.client.builder.AwsClientBuilder;
57
import com.amazonaws.services.s3.AmazonS3;
68
import com.amazonaws.services.s3.AmazonS3Client;
@@ -13,6 +15,7 @@ public class AmazonS3Resolver extends AbstractLocalS3ParameterResolver {
1315

1416
private final AmazonS3ClientBuilder s3Builder = AmazonS3Client.builder()
1517
.enablePathStyleAccess()
18+
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("local-s3-access-key", "local-s3-secret-key")))
1619
.withClientConfiguration(new ClientConfiguration()
1720
.withConnectionTimeout(1000)
1821
.withSocketTimeout(1000));

local-s3-rest/src/main/java/com/robothy/s3/rest/LocalS3.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ public void shutdown() {
149149
}
150150

151151
private void shutdownEventExecutorsGroupIfNeeded(EventExecutorGroup... eventExecutorsList) {
152+
boolean shutdownPerformed = false;
152153
for (EventExecutorGroup eventExecutors : eventExecutorsList) {
153154
if (!eventExecutors.isShuttingDown() && !eventExecutors.isShutdown()) {
154-
try {
155-
eventExecutors.shutdownGracefully().sync();
156-
} catch (InterruptedException e) {
157-
throw new RuntimeException(e);
158-
}
155+
shutdownPerformed = true;
156+
eventExecutors.shutdownGracefully();
159157
}
160158
}
161159

162-
log.info("LocalS3 stopped.");
160+
if (shutdownPerformed) {
161+
log.info("LocalS3 stopped.");
162+
}
163163
}
164164

165165
/**

0 commit comments

Comments
 (0)