You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code base has several Lambda handler classes. I'm implementing an abstract base handler class with some common behaviours. I then implement a lambda specific handler extending the abstract base handler.
...
importsoftware.amazon.codeguruprofilerjavaagent.RequestHandlerWithProfiling;
...
@Log4j2publicabstractclassRequestHandler<I, O> extendsRequestHandlerWithProfiling<I, O> {
static {
// Override the default dimensions to no dimensions by setting the defaultDimensions to an empty listMetricsUtils.defaultDimensions();
}
@Override@Tracing(segmentName = "Handler")
@Logging(clearState = true)
@Metrics(captureColdStart = false) // Disable coldStart metric as it requires non-empty dimensionspublicOrequestHandler(Ii, Contextcontext) {
try {
returnhandle(i, context);
} catch (Exceptione) {
....
}
publicabstractOhandle(Ii, Contextcontext);
}
What were you trying to accomplish?
In a concrete handler, extending the abstract RequestHandler above, I wanted to use the @Validation utility
The end result, is that @Validation under my setup becomes a no-op.
Possible Solution
I'm reporting the above with an example of @Validation annotation, but I believe most other Powertools utilities do share a similar logic in their *Aspect.java classes to leverage LambdaHandlerProcessor for identifying handler methods.
A possible solution is to maybe simply rely on method signature only, rather than forcing a name as already implemented in LambdaHandlerProcessor.placedOnRequestHandler() and LambdaHandlerProcessor.placedOnStreamHandler() and to drop the LambdaHandlerProcessor.isHandlerMethod() check completely.
My code base has several Lambda handler classes. I'm implementing an abstract base handler class with some common behaviours. I then implement a lambda specific handler extending the abstract base handler.
What were you trying to accomplish?
In a concrete handler, extending the abstract
RequestHandler
above, I wanted to use the@Validation
utilityExpected Behavior
The
@Validation
to work.Current Behavior
@Validation
did not result in validating the request. When debugging, I found the followingValidationAspect
leverage'score
'sLambdaHandlerProcessor
to identify handler methods https://github.com/awslabs/aws-lambda-powertools-java/blob/master/powertools-validation/src/main/java/software/amazon/lambda/powertools/validation/internal/ValidationAspect.java#L58 and skips validation if the method is identified as a handlerLambdaHandlerProcessor
makes some strong assumptions about handler method name https://github.com/awslabs/aws-lambda-powertools-java/blob/master/powertools-core/src/main/java/software/amazon/lambda/powertools/core/internal/LambdaHandlerProcessor.java#L39The end result, is that
@Validation
under my setup becomes a no-op.Possible Solution
I'm reporting the above with an example of
@Validation
annotation, but I believe most other Powertools utilities do share a similar logic in their*Aspect.java
classes to leverageLambdaHandlerProcessor
for identifying handler methods.A possible solution is to maybe simply rely on method signature only, rather than forcing a name as already implemented in
LambdaHandlerProcessor.placedOnRequestHandler()
andLambdaHandlerProcessor.placedOnStreamHandler()
and to drop theLambdaHandlerProcessor.isHandlerMethod()
check completely.Steps to Reproduce (for bugs)
Environment
The text was updated successfully, but these errors were encountered: