Skip to content

Commit 5e3e0ce

Browse files
authored
Performance improvements (#4850)
1 parent ce49ac7 commit 5e3e0ce

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "AWS SDK for Java v2",
4+
"contributor": "",
5+
"description": "Fixed bug where the ProfileCredentialsProvider would re-read the credentials file with each request by default."
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "feature",
3+
"category": "AWS SDK for Java v2",
4+
"contributor": "",
5+
"description": "Improved performance of chunk-encoded streaming uploads, like S3's PutObject."
6+
}

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/ProfileCredentialsProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ private ProfileCredentialsProvider(BuilderImpl builder) {
7171
try {
7272
selectedProfileName = Optional.ofNullable(builder.profileName)
7373
.orElseGet(ProfileFileSystemSetting.AWS_PROFILE::getStringValueOrThrow);
74-
75-
selectedProfileSupplier = Optional.ofNullable(builder.profileFile)
76-
.orElseGet(() -> builder.defaultProfileFileLoader);
74+
selectedProfileSupplier =
75+
Optional.ofNullable(builder.profileFile)
76+
.orElseGet(() -> ProfileFileSupplier.fixedProfileFile(builder.defaultProfileFileLoader.get()));
7777

7878
} catch (RuntimeException e) {
7979
// If we couldn't load the credentials provider for some reason, save an exception describing why. This exception

core/http-auth-aws/src/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/chunkedencoding/ChunkedEncodedInputStream.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,20 @@ public static Builder builder() {
7777

7878
@Override
7979
public int read() throws IOException {
80+
return currentChunk().stream().read();
81+
}
82+
83+
@Override
84+
public int read(byte[] b, int off, int len) throws IOException {
85+
return currentChunk().stream().read(b, off, len);
86+
}
87+
88+
private Chunk currentChunk() throws IOException {
8089
if (currentChunk == null || !currentChunk.hasRemaining() && !isFinished) {
8190
currentChunk = getChunk(inputStream);
8291
}
8392

84-
return currentChunk.stream().read();
93+
return currentChunk;
8594
}
8695

8796
/**

0 commit comments

Comments
 (0)