perf(core): check for Credential= before reading the SigV4 scope segment (#8528)

* perf(core): check for Credential= before reading the SigV4 scope segment
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-15 20:27:09 -04:00
1 parent e340c552b0
commit 0d2ea3a9eb
2 files changed
+9 -9

No files matched your search

@@ -105,13 +105,13 @@ public class RegionResolver {
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
return defaultRegion;
}
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
return defaultRegion;
}
String region = SigV4CredentialScope.segment(authorizationHeader, SigV4CredentialScope.Segment.THIRD);
if (region != null) {
return withoutPseudoRegion(region);
}
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
return defaultRegion;
}
Matcher matcher = CREDENTIAL_REGION_PATTERN.matcher(authorizationHeader);
return matcher.find() ? withoutPseudoRegion(matcher.group(1)) : defaultRegion;
}
@@ -198,13 +198,13 @@ public class RegionResolver {
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
return null;
}
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
return null;
}
String region = SigV4CredentialScope.segment(authorizationHeader, SigV4CredentialScope.Segment.THIRD);
if (region != null) {
return withoutPseudoRegion(region);
}
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
return null;
}
Matcher matcher = CREDENTIAL_REGION_PATTERN.matcher(authorizationHeader);
return matcher.find() ? withoutPseudoRegion(matcher.group(1)) : null;
}
@@ -103,13 +103,13 @@ public final class SigV4CredentialScope {
if (authorization == null) {
return Optional.empty();
}
if (!hasCredential(authorization)) {
return Optional.empty();
}
String service = segment(authorization, Segment.SERVICE);
if (service != null) {
return Optional.of(service.toLowerCase(Locale.ROOT));
}
if (!hasCredential(authorization)) {
return Optional.empty();
}
Matcher matcher = SERVICE_PATTERN.matcher(authorization);
if (matcher.find()) {
return Optional.of(matcher.group(1).toLowerCase(Locale.ROOT));