3030import com .amazonaws .services .securitytoken .AWSSecurityTokenServiceClient ;
3131import com .amazonaws .services .securitytoken .AWSSecurityTokenServiceClientBuilder ;
3232
33- import org .apache .http .HttpStatus ;
3433import org .apache .logging .log4j .LogManager ;
3534import org .apache .logging .log4j .Logger ;
3635import org .elasticsearch .ElasticsearchException ;
4443import org .elasticsearch .core .IOUtils ;
4544import org .elasticsearch .core .TimeValue ;
4645import org .elasticsearch .env .Environment ;
46+ import org .elasticsearch .rest .RestStatus ;
4747import org .elasticsearch .watcher .FileChangesListener ;
4848import org .elasticsearch .watcher .FileWatcher ;
4949import org .elasticsearch .watcher .ResourceWatcherService ;
@@ -115,8 +115,8 @@ class S3Service implements Closeable {
115115
116116 /**
117117 * Refreshes the settings for the AmazonS3 clients and clears the cache of
118- * existing clients. New clients will be build using these new settings. Old
119- * clients are usable until released. On release they will be destroyed instead
118+ * existing clients. New clients will be built using these new settings. Old
119+ * clients are usable until released. On release, they will be destroyed instead
120120 * of being returned to the cache.
121121 */
122122 public synchronized void refreshAndClearCache (Map <String , S3ClientSettings > clientsSettings ) {
@@ -126,7 +126,7 @@ public synchronized void refreshAndClearCache(Map<String, S3ClientSettings> clie
126126 this .staticClientSettings = Maps .ofEntries (clientsSettings .entrySet ());
127127 derivedClientSettings = emptyMap ();
128128 assert this .staticClientSettings .containsKey ("default" ) : "always at least have 'default'" ;
129- // clients are built lazily by {@link client}
129+ /* clients are built lazily by {@link # client} */
130130 }
131131
132132 /**
@@ -341,7 +341,8 @@ public void refresh() {
341341 * <ul>
342342 * <li>Reads the location of the web identity token not from AWS_WEB_IDENTITY_TOKEN_FILE, but from a symlink
343343 * in the plugin directory, so we don't need to create a hardcoded read file permission for the plugin.</li>
344- * <li>Supports customization of the STS endpoint via a system property, so we can test it against a test fixture.</li>
344+ * <li>Supports customization of the STS (Security Token Service) endpoint via a system property, so we can
345+ * test it against a test fixture.</li>
345346 * <li>Supports gracefully shutting down the provider and the STS client.</li>
346347 * </ul>
347348 */
@@ -384,7 +385,7 @@ static class CustomWebIdentityTokenCredentialsProvider implements AWSCredentials
384385 if (roleArn == null ) {
385386 LOGGER .warn (
386387 "Unable to use a web identity token for authentication. The AWS_WEB_IDENTITY_TOKEN_FILE environment "
387- + "variable is set, but either AWS_ROLE_ARN is missing"
388+ + "variable is set, but AWS_ROLE_ARN is missing"
388389 );
389390 return ;
390391 }
@@ -528,7 +529,7 @@ interface JvmEnvironment {
528529 return true ;
529530 }
530531 if (exception instanceof AmazonServiceException ase ) {
531- return ase .getStatusCode () == HttpStatus . SC_FORBIDDEN && "InvalidAccessKeyId" .equals (ase .getErrorCode ());
532+ return ase .getStatusCode () == RestStatus . FORBIDDEN . getStatus () && "InvalidAccessKeyId" .equals (ase .getErrorCode ());
532533 }
533534 return false ;
534535 })
0 commit comments