Skip to content

Commit

Permalink
Merge branch '4.9.x' into 5.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelamo committed Dec 23, 2024
2 parents bb8410b + 263e52e commit 5e08737
Show file tree
Hide file tree
Showing 80 changed files with 1,467 additions and 217 deletions.
10 changes: 9 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
"packageRules": [
{
"matchPackagePatterns": ["actions.*"],
"dependencyDashboardApproval": true
"dependencyDashboardApproval": true,
"matchUpdateTypes": ["patch"],
"matchCurrentVersion": "!/^0/",
"automerge": true
},
{
"matchUpdateTypes": ["patch"],
"matchCurrentVersion": "!/^0/",
"automerge": true
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/central-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: v${{ github.event.inputs.release_version }}
- uses: gradle/wrapper-validation-action@v2
- uses: gradle/wrapper-validation-action@v3
- name: Set up JDK
uses: actions/setup-java@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ jobs:
fetch-depth: 0

- name: "🔧 Setup GraalVM CE"
uses: graalvm/[email protected].1
uses: graalvm/[email protected].6
with:
distribution: 'graalvm'
java-version: ${{ matrix.java }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: "🔧 Setup Gradle"
uses: gradle/gradle-build-action@v3.1.0
uses: gradle/gradle-build-action@v3.5.0

- name: "❓ Optional setup step"
run: |
Expand All @@ -70,15 +70,15 @@ jobs:
- name: "📊 Publish Test Report"
if: always()
uses: mikepenz/action-junit-report@v4
uses: mikepenz/action-junit-report@v5
with:
check_name: Java CI / Test Report (${{ matrix.java }})
report_paths: '**/build/test-results/test/TEST-*.xml'
check_retries: 'true'

- name: "📜 Upload binary compatibility check results"
if: matrix.java == '17'
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: binary-compatibility-reports
path: "**/build/reports/binary-compatibility-*.html"
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- uses: gradle/wrapper-validation-action@v2
- uses: gradle/wrapper-validation-action@v3
- name: Set up JDK
uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -66,13 +66,13 @@ jobs:
# Store the hash in a file, which is uploaded as a workflow artifact.
sha256sum $ARTIFACTS | base64 -w0 > artifacts-sha256
- name: Upload build artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: gradle-build-outputs
path: build/repo/${{ steps.publish.outputs.group }}/*/${{ steps.publish.outputs.version }}/*
retention-days: 5
- name: Upload artifacts-sha256
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: artifacts-sha256
path: artifacts-sha256
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
artifacts-sha256: ${{ steps.set-hash.outputs.artifacts-sha256 }}
steps:
- name: Download artifacts-sha256
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifacts-sha256
# The SLSA provenance generator expects the hash digest of artifacts to be passed as a job
Expand All @@ -134,7 +134,7 @@ jobs:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.provenance-subject.outputs.artifacts-sha256 }}"
upload-assets: true # Upload to a new release.
Expand All @@ -146,11 +146,9 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download artifacts
# Important: update actions/download-artifact to v4 only when generator_generic_slsa3.yml is also compatible.
# See https://github.com/slsa-framework/slsa-github-generator/issues/3068
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: gradle-build-outputs
path: build/repo
Expand All @@ -162,6 +160,6 @@ jobs:
- name: Upload assets
# Upload the artifacts to the existing release. Note that the SLSA provenance will
# attest to each artifact file and not the aggregated ZIP file.
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # v2.2.0
with:
files: artifacts.zip
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.io.IOException;

/**
* This seems to be necessary because Serde was not picking the appropriate constructor {@link com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification.S3ObjectEntity(String, Long, String, String, String)}.
* This seems to be necessary because Serde was not picking the appropriate constructor {@code S3EventNotification.S3ObjectEntity(String, Long, String, String, String)}.
*/
@Internal
@Singleton
Expand Down
2 changes: 2 additions & 0 deletions aws-sdk-v2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
compileOnly(libs.awssdk.secretsmanager)
compileOnly(libs.awssdk.servicediscovery)
compileOnly(libs.awssdk.cloudwatchlogs)
compileOnly(libs.awssdk.lambda)

// Tests
testAnnotationProcessor(mn.micronaut.inject.java)
Expand All @@ -41,6 +42,7 @@ dependencies {
testImplementation(libs.awssdk.sqs)
testImplementation(libs.awssdk.ssm)
testImplementation(libs.awssdk.rekognition)
testImplementation(libs.awssdk.lambda)
testRuntimeOnly(libs.jcl.over.slf4j)

testRuntimeOnly(mn.snakeyaml)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright 2017-2024 original authors
*
* 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 io.micronaut.aws.sdk.v2.service.lambda;

import io.micronaut.aws.sdk.v2.service.AWSServiceConfiguration;
import io.micronaut.aws.sdk.v2.service.AwsClientFactory;
import io.micronaut.aws.ua.UserAgentProvider;
import io.micronaut.context.annotation.Bean;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.annotation.Nullable;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
import software.amazon.awssdk.regions.providers.AwsRegionProviderChain;
import software.amazon.awssdk.services.lambda.LambdaAsyncClient;
import software.amazon.awssdk.services.lambda.LambdaAsyncClientBuilder;
import software.amazon.awssdk.services.lambda.LambdaClient;
import software.amazon.awssdk.services.lambda.LambdaClientBuilder;

/**
* Factory that creates {@link LambdaClient} and {@link LambdaAsyncClient}.
* @since 4.7.0
*/
@Factory
class LambdaClientFactory extends AwsClientFactory<LambdaClientBuilder, LambdaAsyncClientBuilder, LambdaClient, LambdaAsyncClient> {
/**
* Constructor.
*
* @param credentialsProvider The credentials provider
* @param regionProvider The region provider
* @param userAgentProvider User-Agent Provider
* @param awsServiceConfiguration AWS Service Configuration
*/
protected LambdaClientFactory(AwsCredentialsProviderChain credentialsProvider,
AwsRegionProviderChain regionProvider,
@Nullable UserAgentProvider userAgentProvider,
@Nullable @Named(LambdaClient.SERVICE_NAME) AWSServiceConfiguration awsServiceConfiguration) {
super(credentialsProvider, regionProvider, userAgentProvider, awsServiceConfiguration);
}

@Override
protected LambdaClientBuilder createSyncBuilder() {
return LambdaClient.builder();
}

@Override
protected LambdaAsyncClientBuilder createAsyncBuilder() {
return LambdaAsyncClient.builder();
}

@Override
@Singleton
public LambdaClientBuilder syncBuilder(SdkHttpClient httpClient) {
return super.syncBuilder(httpClient);
}

@Override
@Bean(preDestroy = "close")
@Singleton
public LambdaClient syncClient(LambdaClientBuilder builder) {
return super.syncClient(builder);
}

@Override
@Singleton
@Requires(beans = SdkAsyncHttpClient.class)
public LambdaAsyncClientBuilder asyncBuilder(SdkAsyncHttpClient httpClient) {
return super.asyncBuilder(httpClient);
}

@Override
@Bean(preDestroy = "close")
@Singleton
@Requires(beans = SdkAsyncHttpClient.class)
public LambdaAsyncClient asyncClient(LambdaAsyncClientBuilder builder) {
return super.asyncClient(builder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2017-2024 original authors
*
* 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.
*/
/**
* Lambda client factory.
* @author Luis Duarte
* @since 4.7.0
*/
@Requires(classes = {LambdaClient.class, LambdaAsyncClient.class})
@Configuration
package io.micronaut.aws.sdk.v2.service.lambda;

import io.micronaut.context.annotation.Configuration;
import io.micronaut.context.annotation.Requires;
import software.amazon.awssdk.services.lambda.LambdaAsyncClient;
import software.amazon.awssdk.services.lambda.LambdaClient;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NettyClientSpec extends ApplicationContextSpecification {

then:
client.configuration().maxConnections() == 123
client.pools.proxyConfiguration == null
client.pools.proxyConfiguration
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.micronaut.aws.sdk.v2.service

import software.amazon.awssdk.services.lambda.LambdaAsyncClient
import software.amazon.awssdk.services.lambda.LambdaClient

class LambdaClientSpec extends ServiceClientSpec<LambdaClient, LambdaAsyncClient> {
@Override
protected String serviceName() {
return LambdaClient.SERVICE_NAME
}

@Override
protected LambdaClient getClient() {
applicationContext.getBean(LambdaClient)
}

protected LambdaAsyncClient getAsyncClient() {
applicationContext.getBean(LambdaAsyncClient)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,7 @@ ApplicationContext getApplicationContext() {
@Override
public void destroy() {
super.destroy();
try {
this.lambdaHandler.close();
} catch (IOException e) {
if (LOG.isErrorEnabled()) {
LOG.error("could not close Handler", e);
}
}
this.lambdaHandler.close();
}

public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DefaultServletToAwsProxyRequestAdapter implements ServletToAwsProxy
public APIGatewayV2HTTPEvent createAwsProxyRequest(@NonNull HttpServletRequest request) {
final boolean isBase64Encoded = true;
return new APIGatewayV2HTTPEvent() {
private String body;

@Override
public Map<String, String> getHeaders() {
Expand Down Expand Up @@ -116,18 +117,20 @@ public boolean getIsBase64Encoded() {

@Override
public String getBody() {
HttpMethod httpMethod = HttpMethod.parse(request.getMethod());
if (HttpMethod.permitsRequestBody(httpMethod)) {
try (InputStream requestBody = request.getInputStream()) {
byte[] data = requestBody.readAllBytes();
if (isBase64Encoded) {
return Base64.getEncoder().encodeToString(data);
if (body == null) {
HttpMethod httpMethod = HttpMethod.parse(request.getMethod());
if (HttpMethod.permitsRequestBody(httpMethod)) {
try (InputStream requestBody = request.getInputStream()) {
byte[] data = requestBody.readAllBytes();
if (isBase64Encoded) {
body = Base64.getEncoder().encodeToString(data);
}
} catch (IOException e) {
// ignore
}
} catch (IOException e) {
// ignore
}
}
return null;
return body;
}
};
}
Expand Down
Loading

0 comments on commit 5e08737

Please sign in to comment.