Skip to content

Commit

Permalink
build(deps): bump software.amazon.awssdk:bom from 2.28.29 to 2.29.9 (#…
Browse files Browse the repository at this point in the history
…1474)

* build(deps): bump software.amazon.awssdk:bom from 2.28.29 to 2.29.9

Bumps software.amazon.awssdk:bom from 2.28.29 to 2.29.9.

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix: refactor graalvm substitution

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sébastien Crocquesel <[email protected]>
  • Loading branch information
dependabot[bot] and scrocquesel authored Nov 9, 2024
1 parent 2a38846 commit 47ab8eb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.TargetElement;

import software.amazon.awssdk.checksums.SdkChecksum;
import software.amazon.awssdk.checksums.internal.CrcCloneOnMarkChecksum;
import software.amazon.awssdk.checksums.internal.CrcCombineOnMarkChecksum;
import software.amazon.awssdk.checksums.internal.SdkCrc32CChecksum;
import software.amazon.awssdk.crt.checksums.CRC64NVME;
import software.amazon.awssdk.http.auth.aws.crt.internal.signer.DefaultAwsCrtV4aHttpSigner;
import software.amazon.awssdk.http.auth.aws.internal.scheme.DefaultAwsV4aAuthScheme;
import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme;
import software.amazon.awssdk.http.auth.aws.signer.AwsV4aHttpSigner;
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
import software.amazon.awssdk.identity.spi.IdentityProvider;
import software.amazon.awssdk.identity.spi.IdentityProviders;

public class CrtSubstitutions {
static final String SOFTWARE_AMAZON_AWSSDK_CRT_PACKAGE = "software.amazon.awssdk.crt";
Expand All @@ -34,6 +35,15 @@ public boolean getAsBoolean() {
}
}

static final class IsCrtPresent implements BooleanSupplier {
private static final IsCrtAbsent IS_CRT_ABSENT = new IsCrtAbsent();

@Override
public boolean getAsBoolean() {
return !IS_CRT_ABSENT.getAsBoolean();
}
}

static final class IsHttpAuthAwsCrtAbsent implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
Expand All @@ -43,43 +53,62 @@ public boolean getAsBoolean() {
}
}

@TargetClass(value = software.amazon.awssdk.http.auth.aws.internal.signer.checksums.Crc32CChecksum.class, onlyWith = IsCrtAbsent.class)
static final class Target_SignerCrc32CChecksum {
/**
* aws sdk tries to create a java 9-based, then crt-based, then fallback to sdk-based checksum
* We can safely use the java 9-based in all cases (java 17 is the minimum since quarkus 3.7)
*/
@TargetClass(value = software.amazon.awssdk.checksums.internal.CrcChecksumProvider.class)
@Substitute()
static final class Target_CrcChecksumProvider {

@Alias
private Checksum crc32c;
private static final String CRT_MODULE = null;
@Alias
private static final String CRT_CRC64NVME_PATH = null;

@Substitute
public Target_SignerCrc32CChecksum() {
crc32c = software.amazon.awssdk.http.auth.aws.internal.signer.checksums.SdkCrc32CChecksum.create();
public static SdkChecksum crc32cImplementation() {

return createJavaCrc32C();
}

/**
* optimize the original version which use reflection to create j.u.z.CRC32C
*/
@Substitute
private Checksum cloneChecksum(Checksum checksum) {
return (Checksum) ((software.amazon.awssdk.http.auth.aws.internal.signer.checksums.SdkCrc32CChecksum) checksum)
.clone();
static SdkChecksum createJavaCrc32C() {
return new CrcCombineOnMarkChecksum(new java.util.zip.CRC32C(), SdkCrc32CChecksum::combine);
}
}

@TargetClass(value = software.amazon.awssdk.http.auth.aws.internal.signer.checksums.Crc32Checksum.class, onlyWith = IsCrtAbsent.class)
static final class Target_SignerCrc32Checksum {
@Delete
static SdkChecksum createCrtCrc32C() {
return null;
}

@Alias
private Checksum crc32;
@Delete
static SdkChecksum createSdkBasedCrc32C() {
return null;
}

@Substitute
public Target_SignerCrc32Checksum() {
crc32 = software.amazon.awssdk.http.auth.aws.internal.signer.checksums.SdkCrc32Checksum.create();
@TargetElement(onlyWith = IsCrtAbsent.class)
static SdkChecksum crc64NvmeCrtImplementation() {
throw new RuntimeException(
"Could not load " + CRT_CRC64NVME_PATH + ". Add dependency on '" + CRT_MODULE
+ "' module to enable CRC64NVME feature.");
}

@Substitute
private Checksum cloneChecksum(Checksum checksum) {

return (Checksum) ((software.amazon.awssdk.http.auth.aws.internal.signer.checksums.SdkCrc32Checksum) checksum)
.clone();
@TargetElement(name = "crc64NvmeCrtImplementation", onlyWith = IsCrtPresent.class)
static SdkChecksum crc64NvmeCrtImplementationCrtPresent() {
return new CrcCloneOnMarkChecksum(new software.amazon.awssdk.crt.checksums.CRC64NVME());
}
}

/**
* aws sdk tries to create a crt-based, then sdk-based checksum
* Force the sdk-based when Crt is absent
*/
@TargetClass(value = software.amazon.awssdk.core.checksums.Crc32Checksum.class, onlyWith = IsCrtAbsent.class)
static final class Target_Crc32Checksum {
@Alias
Expand Down Expand Up @@ -111,45 +140,4 @@ static AwsV4aHttpSigner create() {
"You must add a dependency on the 'software.amazon.awssdk:http-auth-aws-crt' module to enable the CRT-V4a signing feature");
}
}

@TargetClass(value = DefaultAwsV4aAuthScheme.class, onlyWith = IsCrtAbsent.class)
@Delete
final class Target_DefaultAwsV4aAuthScheme {
}

@TargetClass(value = AwsV4aAuthScheme.class, onlyWith = IsHttpAuthAwsCrtAbsent.class)
public interface Target_AwsV4aAuthScheme {

@Substitute
static AwsV4aAuthScheme create() {
return HttpAuthAwsCrtAbsentAwsV4aAuthScheme.DEFAULT;
}
}

/**
* Provide a substitution for DefaultAwsV4aAuthScheme that throws an exception
* at runtime without requiring the optional dependency http-auth-aws-crt.
*/
static class HttpAuthAwsCrtAbsentAwsV4aAuthScheme implements AwsV4aAuthScheme {
private static final HttpAuthAwsCrtAbsentAwsV4aAuthScheme DEFAULT = new HttpAuthAwsCrtAbsentAwsV4aAuthScheme();

public static HttpAuthAwsCrtAbsentAwsV4aAuthScheme create() {
return DEFAULT;
}

@Override
public String schemeId() {
return SCHEME_ID;
}

@Override
public IdentityProvider<AwsCredentialsIdentity> identityProvider(IdentityProviders providers) {
return providers.identityProvider(AwsCredentialsIdentity.class);
}

@Override
public AwsV4aHttpSigner signer() {
return AwsV4aHttpSigner.create(); // will throw
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public class AwsCrtProcessor {
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
void runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClass) {
// CRT and all types that statically init CRT
// https://github.com/search?q=repo%3Aawslabs%2Faws-crt-java+static+%7B+new+CRT%28%29%3B+%7D&type=code
Stream.of(
"software.amazon.awssdk.crt.CRT",
"software.amazon.awssdk.crt.CrtRuntimeException",
"software.amazon.awssdk.crt.CrtResource",
"software.amazon.awssdk.crt.Log",
"software.amazon.awssdk.crt.io.Uri",
"software.amazon.awssdk.crt.checksums.CRC32",
"software.amazon.awssdk.crt.checksums.CRC32C")
"software.amazon.awssdk.crt.checksums.CRC32C",
"software.amazon.awssdk.crt.checksums.CRC64NVME",
"software.amazon.awssdk.crt.utils.StringUtils")
.map(RuntimeInitializedClassBuildItem::new)
.forEach(runtimeInitializedClass::produce);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>3.16.0</quarkus.version>
<awssdk.version>2.28.29</awssdk.version>
<awssdk.version>2.29.9</awssdk.version>
<awscrt.version>0.31.3</awscrt.version>
</properties>
<build>
Expand Down

0 comments on commit 47ab8eb

Please sign in to comment.