Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public class 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 PROVISIONED_CONCURRENCY = "provisioned-concurrency";
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@
}

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

Check failure on line 86 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
SERVICE_NAME = calculateServiceName();
}

public static boolean isColdStart() {
return IS_COLD_START == null;
// If this is not the first invocation, it's definitely not a cold start
// Check if this execution environment was pre-warmed via provisioned concurrency
// Traditional cold start detection - first invocation without provisioned concurrency
return IS_COLD_START == null && !LambdaConstants.PROVISIONED_CONCURRENCY.equals(getenv(LambdaConstants.AWS_LAMBDA_INITIALIZATION_TYPE));
}

public static void coldStartDone() {
Expand Down