forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BugFix] Fix "Connection pool shut down" in S3AFileSystem (StarRocks#…
…50816) Signed-off-by: Smith Cruise <[email protected]> Signed-off-by: zhiminr.ren <[email protected]>
- Loading branch information
1 parent
2afdd52
commit 70bab3f
Showing
12 changed files
with
146 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...c/main/java/com/starrocks/credential/provider/OverwriteAwsDefaultCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.starrocks.credential.provider; | ||
|
||
import software.amazon.awssdk.auth.credentials.AwsCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; | ||
|
||
// We have to implement DefaultCredentialsProvider by ourselves, | ||
// otherwise we may face "java.lang.IllegalStateException: Connection pool shut down" error. | ||
// | ||
// Hadoop S3AFileSystem will call `static AwsCredentialsProvider::create()` to create CredentialsProvider. | ||
// But in DefaultCredentialsProvider::create(), it will only return a global static variable. | ||
// If we close S3AFileSystem, it will also close CredentialsProvider. | ||
// For the next time we create a new S3AFileSystem, it will reuse previous closed CredentialsProvider, then error will be thrown | ||
// You can check details in link: | ||
// https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/troubleshooting.html#faq-connection-pool-shutdown-exception | ||
public class OverwriteAwsDefaultCredentialsProvider implements AwsCredentialsProvider { | ||
public static DefaultCredentialsProvider create() { | ||
return DefaultCredentialsProvider.builder().build(); | ||
} | ||
|
||
// We should not call this function, here will return an anonymous credentials | ||
@Override | ||
public AwsCredentials resolveCredentials() { | ||
// Defense code, return anonymous credentials | ||
return new AwsCredentials() { | ||
@Override | ||
public String accessKeyId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String secretAccessKey() { | ||
return null; | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.