Skip to content
6 changes: 3 additions & 3 deletions examples/powertools-examples-core-utilities/terraform/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>Powertools for AWS Lambda (Java) - Examples - Core Utilities (logging, tracing, metrics) with Terraform</name>
Expand Down Expand Up @@ -101,7 +101,8 @@
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
<transformer
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer" />
</transformers>
</configuration>
</execution>
Expand All @@ -126,7 +127,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<LAMBDA_TASK_ROOT>handler</LAMBDA_TASK_ROOT>
Expand Down
7 changes: 3 additions & 4 deletions examples/powertools-examples-parameters/sam-graalvm/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.lambda.examples</groupId>
<version>2.8.0</version>
Expand Down Expand Up @@ -98,8 +98,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 3.1.0 or higher -->
<version>3.5.4</version>
</plugin>
<plugin>
<groupId>dev.aspectj</groupId>
Expand Down Expand Up @@ -144,7 +142,8 @@
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
<transformer
implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer" />
</transformers>
</configuration>
</execution>
Expand Down
4 changes: 1 addition & 3 deletions examples/powertools-examples-parameters/sam/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>software.amazon.lambda.examples</groupId>
<version>2.8.0</version>
Expand Down Expand Up @@ -72,8 +72,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<!-- JUnit 5 requires Surefire version 3.1.0 or higher -->
<version>3.5.4</version>
</plugin>
<plugin>
<groupId>dev.aspectj</groupId>
Expand Down
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
<aspectj.version>1.9.7</aspectj.version>
<aspectj-maven-plugin.version>1.13.1</aspectj-maven-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
Expand Down Expand Up @@ -625,7 +624,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
@{argLine}
Expand Down
1 change: 0 additions & 1 deletion powertools-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ private LambdaConstants() {
public static final String ROOT_EQUALS = "Root=";
public static final String POWERTOOLS_SERVICE_NAME = "POWERTOOLS_SERVICE_NAME";
public static final String SERVICE_UNDEFINED = "service_undefined";
public static final String AWS_LAMBDA_INITIALIZATION_TYPE = "AWS_LAMBDA_INITIALIZATION_TYPE";
public static final String ON_DEMAND_INVOCATION_TYPE = "on-demand";
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,19 @@
}

// Method used for testing purposes
protected static void resetServiceName() {

Check failure on line 91 in powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessor.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid protected methods in a final class that doesnt extend anything other than Object. Change to private or package access.

Do not use protected methods in most final classes since they cannot be subclassed. This should only be allowed in final classes that extend other classes with protected methods (whose visibility cannot be reduced). Clarify your intent by using private or package access modifiers instead. AvoidProtectedMethodInFinalClassNotExtending (Priority: 1, Ruleset: Code Style) https://docs.pmd-code.org/snapshot/pmd_rules_java_codestyle.html#avoidprotectedmethodinfinalclassnotextending
serviceName = calculateServiceName();
}

public static boolean isColdStart() {
return isColdStart == null;
if (isColdStart != null) {
return isColdStart;
}

String initType = System.getenv(LambdaConstants.AWS_LAMBDA_INITIALIZATION_TYPE);
isColdStart = LambdaConstants.ON_DEMAND_INVOCATION_TYPE.equals(initType);

return isColdStart;
}

public static void coldStartDone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void extractContext_notKnownHandler() {
}

@Test
@SetEnvironmentVariable(key = LambdaConstants.AWS_LAMBDA_INITIALIZATION_TYPE, value = LambdaConstants.ON_DEMAND_INVOCATION_TYPE)
void isColdStart() {
boolean isColdStart = LambdaHandlerProcessor.isColdStart();

Expand Down
2 changes: 0 additions & 2 deletions powertools-e2e-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<goals>
Expand All @@ -241,7 +240,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<goals>
Expand Down
3 changes: 1 addition & 2 deletions powertools-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -182,11 +181,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_LAMBDA_LOG_FORMAT>JSON</AWS_LAMBDA_LOG_FORMAT>
<POWERTOOLS_SERVICE_NAME>testService</POWERTOOLS_SERVICE_NAME>
<AWS_LAMBDA_INITIALIZATION_TYPE>on-demand</AWS_LAMBDA_INITIALIZATION_TYPE>
</environmentVariables>
</configuration>
</plugin>
Expand Down
3 changes: 1 addition & 2 deletions powertools-logging/powertools-logging-log4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -204,12 +203,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<POWERTOOLS_SERVICE_NAME>testLog4j</POWERTOOLS_SERVICE_NAME>
<AWS_REGION>eu-central-1</AWS_REGION>
<_X_AMZN_TRACE_ID>Root=1-63441c4a-abcdef012345678912345678</_X_AMZN_TRACE_ID>
<AWS_LAMBDA_INITIALIZATION_TYPE>on-demand</AWS_LAMBDA_INITIALIZATION_TYPE>
</environmentVariables>
</configuration>
</plugin>
Expand Down
3 changes: 1 addition & 2 deletions powertools-logging/powertools-logging-logback/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -203,12 +202,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<POWERTOOLS_SERVICE_NAME>testLogback</POWERTOOLS_SERVICE_NAME>
<AWS_REGION>eu-central-1</AWS_REGION>
<_X_AMZN_TRACE_ID>Root=1-63441c4a-abcdef012345678912345678</_X_AMZN_TRACE_ID>
<AWS_LAMBDA_INITIALIZATION_TYPE>on-demand</AWS_LAMBDA_INITIALIZATION_TYPE>
</environmentVariables>
</configuration>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions powertools-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<configuration>
<environmentVariables>
<AWS_EMF_ENVIRONMENT>Lambda</AWS_EMF_ENVIRONMENT>
<AWS_LAMBDA_INITIALIZATION_TYPE>on-demand</AWS_LAMBDA_INITIALIZATION_TYPE>
</environmentVariables>
</configuration>
</plugin>
Expand Down
2 changes: 0 additions & 2 deletions powertools-parameters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_REGION>eu-central-1</AWS_REGION>
Expand All @@ -98,7 +97,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
2 changes: 0 additions & 2 deletions powertools-parameters/powertools-parameters-appconfig/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -175,7 +174,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_REGION>eu-central-1</AWS_REGION>
Expand Down
2 changes: 0 additions & 2 deletions powertools-parameters/powertools-parameters-dynamodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -176,7 +175,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_REGION>eu-central-1</AWS_REGION>
Expand Down
2 changes: 0 additions & 2 deletions powertools-parameters/powertools-parameters-secrets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down Expand Up @@ -176,7 +175,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_REGION>eu-central-1</AWS_REGION>
Expand Down
2 changes: 0 additions & 2 deletions powertools-parameters/powertools-parameters-ssm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<environmentVariables>
<AWS_REGION>eu-central-1</AWS_REGION>
Expand All @@ -123,7 +122,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
1 change: 0 additions & 1 deletion powertools-parameters/powertools-parameters-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
1 change: 0 additions & 1 deletion powertools-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
15 changes: 14 additions & 1 deletion powertools-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<AWS_LAMBDA_INITIALIZATION_TYPE>on-demand</AWS_LAMBDA_INITIALIZATION_TYPE>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>generate-graalvm-files</id>
Expand All @@ -137,7 +151,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
Expand Down
Loading