aws-powertools / powertools-lambda-java

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/java/
MIT No Attribution
290 stars 88 forks source link

Error upgrading aws-java-sdk-v2 monrepo #1685

Closed devagx closed 2 months ago

devagx commented 4 months ago

when upgrading from version 2.26.4 to 2.26.12 I get this error in my java lambda. errors on software.amazon.lambda.powertools.parameters.ParamManager.getSsmProvider() when upgrading

Any help appreciated

jeromevdl commented 4 months ago

Hi @devagx , thanks for reporting this.

Could you tell us which version of powertools you're using? Also could you share a piece of code to reproduce it? Last question: do you confirm it was working with the older version of the SDK?

devagx commented 4 months ago

hi, its powertools v 1.18.0. It was working with version 2.26.4. The code:

private SSMProvider ssmProvider;

public SSMProvider getSsmProvider() { if (ssmProvider == null) { ssmProvider = ParamManager.getSsmProvider(); } return ssmProvider.withDecryption();

}

thanks

jeromevdl commented 4 months ago

So i've just tried with the example, with JDK 8, 11, 17, 21 and could not reproduce...

<dependencies>
        <dependency>
            <groupId>software.amazon.lambda</groupId>
            <artifactId>powertools-logging</artifactId>
            <version>1.18.0</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.lambda</groupId>
            <artifactId>powertools-parameters</artifactId>
            <version>1.18.0</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>secretsmanager</artifactId>
            <version>2.26.12</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>ssm</artifactId>
            <version>2.26.12</version>
        </dependency>
...

Also I think you removed the stack trace from the issue so it's hard to know what the error is...

devagx commented 4 months ago
"thrown": {
    "message": "Unexpected error occurred. Please raise issue at https://github.com/aws-powertools/powertools-lambda-java/issues",
    "name": "java.lang.RuntimeException",
    "extendedStackTrace": [
        {
            "class": "software.amazon.lambda.powertools.parameters.ParamManager",
            "method": "createProvider",
            "file": "ParamManager.java",
            "line": 189
        },
        {
            "class": "java.util.concurrent.ConcurrentHashMap",
            "method": "computeIfAbsent",
            "file": null,
            "line": -1
        },
        {
            "class": "software.amazon.lambda.powertools.parameters.ParamManager",
            "method": "getProvider",
            "file": "ParamManager.java",
            "line": 55
        },
        {
            "class": "software.amazon.lambda.powertools.parameters.ParamManager",
            "method": "getSsmProvider",
            "file": "ParamManager.java",
            "line": 75
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.properties.AmazonMQProperties",
            "method": "initialize",
            "file": "AmazonMQProperties.java",
            "line": 26
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.amazonmq.SendMessageToQueue",
            "method": "getJmsQueueProperties",
            "file": "SendMessageToQueue.java",
            "line": 213
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.amazonmq.SendMessageToQueue",
            "method": "validatePropertiesAndCreateConnectionFactory",
            "file": "SendMessageToQueue.java",
            "line": 72
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.amazonmq.SendMessageToQueue",
            "method": "sendMessageToTheQueue",
            "file": "SendMessageToQueue.java",
            "line": 47
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler",
            "method": "processMessage",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 96
        },
        {
            "class": "software.amazon.lambda.powertools.batch.builder.AbstractBatchMessageHandlerBuilder",
            "method": "lambda$buildWithMessageHandler$1",
            "file": "AbstractBatchMessageHandlerBuilder.java",
            "line": 132
        },
        {
            "class": "software.amazon.lambda.powertools.batch.handler.SqsBatchMessageHandler",
            "method": "processBatch",
            "file": "SqsBatchMessageHandler.java",
            "line": 78
        },
        {
            "class": "software.amazon.lambda.powertools.batch.handler.SqsBatchMessageHandler",
            "method": "processBatch",
            "file": "SqsBatchMessageHandler.java",
            "line": 33
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler",
            "method": "handleRequest_aroundBody0",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 68
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler$AjcClosure1",
            "method": "run",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 1
        },
        {
            "class": "org.aspectj.runtime.reflect.JoinPointImpl",
            "method": "proceed",
            "file": "JoinPointImpl.java",
            "line": 252
        },
        {
            "class": "software.amazon.lambda.powertools.logging.internal.LambdaLoggingAspect",
            "method": "around",
            "file": "LambdaLoggingAspect.java",
            "line": 138
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler",
            "method": "handleRequest_aroundBody2",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 67
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler$AjcClosure3",
            "method": "run",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 1
        },
        {
            "class": "org.aspectj.runtime.reflect.JoinPointImpl",
            "method": "proceed",
            "file": "JoinPointImpl.java",
            "line": 252
        },
        {
            "class": "software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAspect",
            "method": "around",
            "file": "LambdaMetricsAspect.java",
            "line": 100
        },
        {
            "class": "uk.co.cdl.documents.as.a.service.atl.MyAppTranslatorRequestHandler",
            "method": "handleRequest",
            "file": "MyAppTranslatorRequestHandler.java",
            "line": 67
        },
        {
            "class": "jdk.internal.reflect.DirectMethodHandleAccessor",
            "method": "invoke",
            "file": null,
            "line": -1
        },
        {
            "class": "java.lang.reflect.Method",
            "method": "invoke",
            "file": null,
            "line": -1
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$PojoMethodRequestHandler",
            "method": "handleRequest",
            "file": "EventHandlerLoader.java",
            "line": 286
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$PojoHandlerAsStreamHandler",
            "method": "handleRequest",
            "file": "EventHandlerLoader.java",
            "line": 203
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2",
            "method": "call",
            "file": "EventHandlerLoader.java",
            "line": 907
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.AWSLambda",
            "method": "startRuntime",
            "file": "AWSLambda.java",
            "line": 239
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.AWSLambda",
            "method": "startRuntime",
            "file": "AWSLambda.java",
            "line": 191
        },
        {
            "class": "com.amazonaws.services.lambda.runtime.api.client.AWSLambda",
            "method": "main",
            "file": "AWSLambda.java",
            "line": 181
        }
    ]
},
devagx commented 4 months ago

sorry just noticed on this aswell the powertools-logging and powertools-metrics are using an aspect

jeromevdl commented 4 months ago

I'm sorry but I cannot reproduce your issue with our sample. If you manage to extract and share a peace of code that reproduce the problem, it would help a lot. Also not sure about your last comment about aspects...

jeromevdl commented 4 months ago

@devagx, did you manage to solve your problem, or can you share a complete example that reproduces it?

jeromevdl commented 2 months ago

Closing as no update.