|
@@ -125,13 +125,14 @@ public class ITestS3ATemporaryCredentials extends AbstractS3ATestBase {
|
|
|
credentials,
|
|
|
getStsEndpoint(conf),
|
|
|
getStsRegion(conf));
|
|
|
- STSClientFactory.STSClient clientConnection =
|
|
|
- STSClientFactory.createClientConnection(
|
|
|
- builder.build(),
|
|
|
- new Invoker(new S3ARetryPolicy(conf), Invoker.LOG_EVENT));
|
|
|
- Credentials sessionCreds = clientConnection
|
|
|
- .requestSessionCredentials(TEST_SESSION_TOKEN_DURATION_SECONDS,
|
|
|
- TimeUnit.SECONDS);
|
|
|
+ Credentials sessionCreds;
|
|
|
+ try (STSClientFactory.STSClient clientConnection =
|
|
|
+ STSClientFactory.createClientConnection(builder.build(),
|
|
|
+ new Invoker(new S3ARetryPolicy(conf), Invoker.LOG_EVENT))) {
|
|
|
+ sessionCreds = clientConnection
|
|
|
+ .requestSessionCredentials(
|
|
|
+ TEST_SESSION_TOKEN_DURATION_SECONDS, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
|
|
|
// clone configuration so changes here do not affect the base FS.
|
|
|
Configuration conf2 = new Configuration(conf);
|
|
@@ -379,11 +380,12 @@ public class ITestS3ATemporaryCredentials extends AbstractS3ATestBase {
|
|
|
Invoker invoker = new Invoker(new S3ARetryPolicy(conf),
|
|
|
LOG_AT_ERROR);
|
|
|
|
|
|
- STSClientFactory.STSClient stsClient
|
|
|
- = STSClientFactory.createClientConnection(tokenService,
|
|
|
- invoker);
|
|
|
-
|
|
|
- return stsClient.requestSessionCredentials(30, TimeUnit.MINUTES);
|
|
|
+ try (STSClientFactory.STSClient stsClient =
|
|
|
+ STSClientFactory.createClientConnection(
|
|
|
+ tokenService, invoker)) {
|
|
|
+ return stsClient.requestSessionCredentials(
|
|
|
+ 30, TimeUnit.MINUTES);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -413,6 +415,7 @@ public class ITestS3ATemporaryCredentials extends AbstractS3ATestBase {
|
|
|
return sc.toString();
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
@Test
|
|
|
public void testEmptyTemporaryCredentialValidation() throws Throwable {
|
|
|
Configuration conf = new Configuration();
|