diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index a4ab6e7de..a75c13b52 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -3,7 +3,6 @@ name: Build Docs on: pull_request: branches: - - main - v2 paths: - 'docs/**' diff --git a/.github/workflows/pr_artifacts_size.yml b/.github/workflows/pr_artifacts_size.yml index e7e3158e3..c4d29205b 100644 --- a/.github/workflows/pr_artifacts_size.yml +++ b/.github/workflows/pr_artifacts_size.yml @@ -3,13 +3,11 @@ name: Artifacts Size on: pull_request: branches: - - main - v2 paths: - 'powertools-batch/**' - 'powertools-cloudformation/**' - - 'powertools-core/**' # not in v2 - - 'powertools-common/**' # v2 only + - 'powertools-common/**' - 'powertools-e2e-tests/**' - 'powertools-idempotency-core/**' - 'powertools-idempotency-dynamodb/**' @@ -18,8 +16,6 @@ on: - 'powertools-metrics/**' - 'powertools-parameters/**' - 'powertools-serialization/**' - - 'powertools-sqs/**' # not in v2 - - 'powertools-test-suite/**' # not in v2 - 'powertools-tracing/**' - 'powertools-validation/**' - 'pom.xml' diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 1ff2dc48b..2079bcb6b 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -3,11 +3,11 @@ name: Build on: pull_request: branches: - - main + - v2 paths: - 'powertools-batch/**' - 'powertools-cloudformation/**' - - 'powertools-core/**' + - 'powertools-common/**' - 'powertools-e2e-tests/**' - 'powertools-idempotency/**' - 'powertools-large-messages/**' @@ -15,8 +15,6 @@ on: - 'powertools-metrics/**' - 'powertools-parameters/**' - 'powertools-serialization/**' - - 'powertools-sqs/**' - - 'powertools-test-suite/**' - 'powertools-tracing/**' - 'powertools-validation/**' - 'examples/**' @@ -25,11 +23,11 @@ on: - '.github/workflows/**' push: branches: - - main + - v2 paths: - 'powertools-batch/**' - 'powertools-cloudformation/**' - - 'powertools-core/**' + - 'powertools-common/**' - 'powertools-e2e-tests/**' - 'powertools-idempotency/**' - 'powertools-large-messages/**' @@ -37,8 +35,6 @@ on: - 'powertools-metrics/**' - 'powertools-parameters/**' - 'powertools-serialization/**' - - 'powertools-sqs/**' - - 'powertools-test-suite/**' - 'powertools-tracing/**' - 'powertools-validation/**' - 'examples/**' @@ -70,12 +66,10 @@ jobs: - name: Build with Maven run: mvn -B install --file pom.xml - name: Build Gradle Example - Java - if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8 - working-directory: examples/powertools-examples-core/gradle + working-directory: examples/powertools-examples-core-utilities/gradle run: ./gradlew build - name: Build Gradle Example - Kotlin - if: ${{ matrix.java == '8' }} # Gradle example can only be built on Java 8 - working-directory: examples/powertools-examples-core/kotlin + working-directory: examples/powertools-examples-core-utilities/kotlin run: ./gradlew build - name: Upload coverage to Codecov uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 diff --git a/.github/workflows/pr_build_v2.yml b/.github/workflows/pr_build_v2.yml deleted file mode 100644 index 2079bcb6b..000000000 --- a/.github/workflows/pr_build_v2.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Build - -on: - pull_request: - branches: - - v2 - paths: - - 'powertools-batch/**' - - 'powertools-cloudformation/**' - - 'powertools-common/**' - - 'powertools-e2e-tests/**' - - 'powertools-idempotency/**' - - 'powertools-large-messages/**' - - 'powertools-logging/**' - - 'powertools-metrics/**' - - 'powertools-parameters/**' - - 'powertools-serialization/**' - - 'powertools-tracing/**' - - 'powertools-validation/**' - - 'examples/**' - - 'pom.xml' - - 'examples/pom.xml' - - '.github/workflows/**' - push: - branches: - - v2 - paths: - - 'powertools-batch/**' - - 'powertools-cloudformation/**' - - 'powertools-common/**' - - 'powertools-e2e-tests/**' - - 'powertools-idempotency/**' - - 'powertools-large-messages/**' - - 'powertools-logging/**' - - 'powertools-metrics/**' - - 'powertools-parameters/**' - - 'powertools-serialization/**' - - 'powertools-tracing/**' - - 'powertools-validation/**' - - 'examples/**' - - 'pom.xml' - - 'examples/pom.xml' - - '.github/workflows/**' -jobs: - build-corretto: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - matrix: - java: [11, 17, 21] - name: Java ${{ matrix.java }} - env: - JAVA: ${{ matrix.java }} - AWS_REGION: eu-west-1 - permissions: - id-token: write # needed to interact with GitHub's OIDC Token endpoint. - contents: read - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - name: Setup java - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0 - with: - distribution: 'corretto' - java-version: ${{ matrix.java }} - cache: 'maven' - - name: Build with Maven - run: mvn -B install --file pom.xml - - name: Build Gradle Example - Java - working-directory: examples/powertools-examples-core-utilities/gradle - run: ./gradlew build - - name: Build Gradle Example - Kotlin - working-directory: examples/powertools-examples-core-utilities/kotlin - run: ./gradlew build - - name: Upload coverage to Codecov - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 - if: ${{ matrix.java == '11' }} # publish results once - with: - files: ./powertools-cloudformation/target/site/jacoco/jacoco.xml,./powertools-core/target/site/jacoco/jacoco.xml,./powertools-idempotency/target/site/jacoco/jacoco.xml,./powertools-logging/target/site/jacoco/jacoco.xml,./powertools-metrics/target/site/jacoco/jacoco.xml,./powertools-parameters/target/site/jacoco/jacoco.xml,./powertools-serialization/target/site/jacoco/jacoco.xml,./powertools-sqs/target/site/jacoco/jacoco.xml,./powertools-tracing/target/site/jacoco/jacoco.xml,./powertools-validation/target/site/jacoco/jacoco.xml,./powertools-large-messages/target/site/jacoco/jacoco.xml,./powertools-batch/target/site/jacoco/jacoco.xml - savepr: - runs-on: ubuntu-latest - name: Save PR number if running on PR by dependabot - if: github.actor == 'dependabot[bot]' - steps: - - name: Create Directory and save issue - run: | - mkdir -p ./pr - echo ${{ github.event.number }} - echo ${{ github.event.number }} > ./pr/NR - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - name: Upload artifact - with: - name: pr - path: pr/ diff --git a/.github/workflows/pr_iac_lint.yml b/.github/workflows/pr_iac_lint.yml index 09ba5f02b..531ccbbcb 100644 --- a/.github/workflows/pr_iac_lint.yml +++ b/.github/workflows/pr_iac_lint.yml @@ -3,11 +3,9 @@ name: Validate IaC on: push: branches: - - main - v2 pull_request: branches: - - main - v2 paths: - 'examples/**' diff --git a/.github/workflows/run-e2e-tests-v2.yml b/.github/workflows/run-e2e-tests-v2.yml deleted file mode 100644 index 255c89cfe..000000000 --- a/.github/workflows/run-e2e-tests-v2.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Run end-to-end tests - -on: - workflow_dispatch: - - push: - branches: - - v2 - paths: # add other modules when there are under e2e tests - - 'powertools-e2e-tests/**' - - 'powertools-batch/**' - - 'powertools-core/**' - - 'powertools-common/**' - - 'powertools-idempotency/**' - - 'powertools-large-message/**' - - 'powertools-logging/**' - - 'powertools-metrics/**' - - 'powertools-parameters/**' - - 'powertools-serialization/**' - - 'powertools-tracing/**' - - 'pom.xml' - - '.github/workflows/**' - - pull_request: - branches: - - v2 - paths: - - 'powertools-e2e-tests/**' - -jobs: - e2e: - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - java: [ 11, 17, 21 ] - name: End-to-end tests java${{ matrix.java }} - env: - AWS_DEFAULT_REGION: eu-west-1 - JAVA_VERSION: ${{ matrix.java }} - permissions: - id-token: write # needed to interact with GitHub's OIDC Token endpoint. - contents: read - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - name: Setup java - uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0 - with: - distribution: 'corretto' - java-version: ${{ matrix.java }} - cache: maven - - name: Setup AWS credentials - uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Run e2e test with Maven - run: mvn -DskipTests install --file pom.xml && mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml \ No newline at end of file diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 86d66156b..255c89cfe 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -5,7 +5,7 @@ on: push: branches: - - main + - v2 paths: # add other modules when there are under e2e tests - 'powertools-e2e-tests/**' - 'powertools-batch/**' @@ -23,7 +23,7 @@ on: pull_request: branches: - - main + - v2 paths: - 'powertools-e2e-tests/**' @@ -54,7 +54,5 @@ jobs: with: role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }} aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Build with Maven - run: mvn -DskipTests install --file pom.xml - name: Run e2e test with Maven - run: mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml + run: mvn -DskipTests install --file pom.xml && mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml \ No newline at end of file diff --git a/.github/workflows/spotbugs.yml b/.github/workflows/spotbugs.yml index a75cba8f1..106905a70 100644 --- a/.github/workflows/spotbugs.yml +++ b/.github/workflows/spotbugs.yml @@ -3,7 +3,6 @@ name: SpotBugs on: pull_request: branches: - - main - v2 paths: - 'powertools-cloudformation/**' diff --git a/examples/README.md b/examples/README.md index 2e34513db..41640b5ad 100644 --- a/examples/README.md +++ b/examples/README.md @@ -14,7 +14,6 @@ Each example can be copied from its subdirectory and used independently of the r * [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API * [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function * [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads -* [powertools-examples-sqs](powertools-examples-sqs) - Processes SQS batch requests (**Deprecated** - will be replaced by `powertools-examples-batch` in version 2 of this library) * [powertools-examples-validation](powertools-examples-validation) - Uses the validation module to validate user requests received via API Gateway * [powertools-examples-cloudformation](powertools-examples-cloudformation) - Deploys a Cloudformation custom resource * [powertools-examples-batch](powertools-examples-batch) - Examples for each of the different batch processing deployments diff --git a/powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java b/powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java index fe18000d4..215151d44 100644 --- a/powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java +++ b/powertools-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java @@ -47,23 +47,6 @@ public static Builder builder() { return new Builder(); } - /** - * Creates a failed Response with no physicalResourceId set. Powertools for AWS Lambda (Java) will set the physicalResourceId to the - * Lambda LogStreamName - *
- * The value returned for a PhysicalResourceId can change custom resource update operations. If the value returned - * is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes - * the update as a replacement and sends a delete request to the old resource. For more information, - * see AWS::CloudFormation::CustomResource. - * - * @return a failed Response with no value. - * @deprecated this method is not safe. Provide a physicalResourceId. - */ - @Deprecated - public static Response failed() { - return new Response(null, Status.FAILED, null, false); - } - /** * Creates a failed Response with a given physicalResourceId. * @@ -80,23 +63,6 @@ public static Response failed(String physicalResourceId) { return new Response(null, Status.FAILED, physicalResourceId, false); } - /** - * Creates a successful Response with no physicalResourceId set. Powertools for AWS Lambda (Java) will set the physicalResourceId to the - * Lambda LogStreamName - *
- * The value returned for a PhysicalResourceId can change custom resource update operations. If the value returned
- * is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes
- * the update as a replacement and sends a delete request to the old resource. For more information,
- * see AWS::CloudFormation::CustomResource.
- *
- * @return a success Response with no physicalResourceId value.
- * @deprecated this method is not safe. Provide a physicalResourceId.
- */
- @Deprecated
- public static Response success() {
- return new Response(null, Status.SUCCESS, null, false);
- }
-
/**
* Creates a successful Response with a given physicalResourceId.
*
diff --git a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponseTest.java b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponseTest.java
index 51f0e95f9..0701c98fe 100644
--- a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponseTest.java
+++ b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponseTest.java
@@ -38,7 +38,7 @@
import software.amazon.awssdk.utils.StringInputStream;
import software.amazon.lambda.powertools.cloudformation.CloudFormationResponse.ResponseBody;
-public class CloudFormationResponseTest {
+class CloudFormationResponseTest {
/**
* Creates a mock CloudFormationCustomResourceEvent with a non-null response URL.
@@ -215,7 +215,7 @@ void reasonIncludesLogStreamName() {
}
@Test
- public void sendWithNoResponseData() throws Exception {
+ void sendWithNoResponseData() throws Exception {
CloudFormationCustomResourceEvent event = mockCloudFormationCustomResourceEvent();
Context context = mock(Context.class);
CloudFormationResponse cfnResponse = testableCloudFormationResponse();
@@ -237,7 +237,7 @@ public void sendWithNoResponseData() throws Exception {
}
@Test
- public void sendWithNonNullResponseData() throws Exception {
+ void sendWithNonNullResponseData() throws Exception {
CloudFormationCustomResourceEvent event = mockCloudFormationCustomResourceEvent();
Context context = mock(Context.class);
CloudFormationResponse cfnResponse = testableCloudFormationResponse();
@@ -289,7 +289,7 @@ void responseBodyStreamSuccessResponse() throws Exception {
Context context = mock(Context.class);
CloudFormationResponse cfnResponse = testableCloudFormationResponse();
- StringInputStream stream = cfnResponse.responseBodyStream(event, context, Response.success());
+ StringInputStream stream = cfnResponse.responseBodyStream(event, context, Response.success(null));
String expectedJson = "{" +
"\"Status\":\"SUCCESS\"," +
@@ -310,7 +310,7 @@ void responseBodyStreamFailedResponse() throws Exception {
Context context = mock(Context.class);
CloudFormationResponse cfnResponse = testableCloudFormationResponse();
- StringInputStream stream = cfnResponse.responseBodyStream(event, context, Response.failed());
+ StringInputStream stream = cfnResponse.responseBodyStream(event, context, Response.failed(null));
String expectedJson = "{" +
"\"Status\":\"FAILED\"," +
diff --git a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/ResponseTest.java b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/ResponseTest.java
index 37fe73d0f..e577aecca 100644
--- a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/ResponseTest.java
+++ b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/ResponseTest.java
@@ -22,7 +22,7 @@
import java.util.Map;
import org.junit.jupiter.api.Test;
-public class ResponseTest {
+class ResponseTest {
@Test
void defaultValues() {
@@ -92,7 +92,7 @@ void jsonMapValueWithDefaultObjectMapper() {
String expected = "{\"foo\":\"bar\"}";
assertThat(response.getJsonNode()).isNotNull();
- assertThat(response.getJsonNode().toString()).isEqualTo(expected);
+ assertThat(response.getJsonNode()).hasToString(expected);
assertThat(response.toString()).contains("JSON = " + expected);
}
@@ -105,7 +105,7 @@ void jsonObjectValueWithDefaultObjectMapper() {
.build();
String expected = "{\"PropertyWithLongName\":\"test\"}";
- assertThat(response.getJsonNode().toString()).isEqualTo(expected);
+ assertThat(response.getJsonNode()).hasToString(expected);
assertThat(response.toString()).contains("JSON = " + expected);
}
@@ -119,7 +119,7 @@ void jsonObjectValueWithNullObjectMapper() {
.build();
String expected = "{\"PropertyWithLongName\":\"test\"}";
- assertThat(response.getJsonNode().toString()).isEqualTo(expected);
+ assertThat(response.getJsonNode()).hasToString(expected);
assertThat(response.toString()).contains("JSON = " + expected);
}
@@ -135,7 +135,7 @@ void jsonObjectValueWithCustomObjectMapper() {
.build();
String expected = "{\"property-with-long-name\":10}";
- assertThat(response.getJsonNode().toString()).isEqualTo(expected);
+ assertThat(response.getJsonNode()).hasToString(expected);
assertThat(response.toString()).contains("JSON = " + expected);
}
@@ -154,13 +154,13 @@ void jsonObjectValueWithPostConfiguredObjectMapper() {
customMapper.setPropertyNamingStrategy(PropertyNamingStrategies.UPPER_CAMEL_CASE);
String expected = "{\"property-with-long-name\":10}";
- assertThat(response.getJsonNode().toString()).isEqualTo(expected);
+ assertThat(response.getJsonNode()).hasToString(expected);
assertThat(response.toString()).contains("JSON = " + expected);
}
@Test
void successFactoryMethod() {
- Response response = Response.success();
+ Response response = Response.success(null);
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(Response.Status.SUCCESS);
@@ -168,7 +168,7 @@ void successFactoryMethod() {
@Test
void failedFactoryMethod() {
- Response response = Response.failed();
+ Response response = Response.failed(null);
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(Response.Status.FAILED);
diff --git a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/handlers/NoPhysicalResourceIdSetHandler.java b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/handlers/NoPhysicalResourceIdSetHandler.java
index 2bbda309f..e55abca03 100644
--- a/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/handlers/NoPhysicalResourceIdSetHandler.java
+++ b/powertools-cloudformation/src/test/java/software/amazon/lambda/powertools/cloudformation/handlers/NoPhysicalResourceIdSetHandler.java
@@ -23,16 +23,16 @@ public class NoPhysicalResourceIdSetHandler extends AbstractCustomResourceHandle
@Override
protected Response create(CloudFormationCustomResourceEvent event, Context context) {
- return Response.success();
+ return Response.success(null);
}
@Override
protected Response update(CloudFormationCustomResourceEvent event, Context context) {
- return Response.success();
+ return Response.success(null);
}
@Override
protected Response delete(CloudFormationCustomResourceEvent event, Context context) {
- return Response.success();
+ return Response.success(null);
}
}
diff --git a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
index ba53bad1f..6c3a89a65 100644
--- a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
+++ b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
@@ -14,7 +14,6 @@
package software.amazon.lambda.powertools.metrics;
-import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;
import static software.amazon.lambda.powertools.common.internal.LambdaHandlerProcessor.getXrayTraceId;
import static software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAspect.REQUEST_ID_PROPERTY;
@@ -63,23 +62,6 @@ public static void defaultDimensions(final DimensionSet... dimensionSets) {
MetricsUtils.defaultDimensions = dimensionSets;
}
- /**
- * Configure default dimension to be used by logger.
- * By default, @{@link Metrics} annotation captures configured service as a dimension Service
- *
- * @param dimensionSet Default value of dimension set for logger
- * @deprecated use {@link #defaultDimensions(DimensionSet...)} instead
- */
- @Deprecated
- public static void defaultDimensionSet(final DimensionSet dimensionSet) {
- requireNonNull(dimensionSet, "Null dimension set not allowed");
-
- if (dimensionSet.getDimensionKeys().size() > 0) {
- defaultDimensions(dimensionSet);
- }
- }
-
-
/**
* Add and immediately flush a single metric. It will use the default namespace
* specified either on {@link Metrics} annotation or via POWERTOOLS_METRICS_NAMESPACE env var.
@@ -146,20 +128,6 @@ public static void withMetricsLogger(final Consumer