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
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version: 1.6
Implementations:Core
Framework version:SpringBoot 2 v1.7-SNAPSHOT
Frontend service:HTTP API
Deployment method:SAM
Scenario
I'm trying to instrument an AWS Lambda function with a Java agent containing a Servlet instrumentation. In the instrumentation of Filter#init(FilterConfig), the agent calls getServletContext() (via reflection) on the FilterConfig, which returns a com.amazonaws.serverless.proxy.internal.servlet.AwsServletContext object. Then, again via reflection, the agent calls getServletContextName().
getServletContextName() throws an UnsupportedOperationException (wrapped in an InvocationTargetException due to reflection).
Steps to reproduce
Instantiate an AwsServletContext object.
Call getServletContextName() on it.
Log output
Not the full logs since they're not relevant, but here's the InvocationTargetException i got when discovering this issue:
2022-02-04 13:51:12.139 UTC [00000001] [ServletIntrospection] Exception in introspection method "registerFilter". java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at agent.introspection.util.classvalue.MethodClassValue.invoke(MethodClassValue.java:71)
at agent.introspection.servlet.ServletIntrospection.getServletContextName(ServletIntrospection.java:382)
at agent.introspection.servlet.ServletIntrospection.registerFilter(ServletIntrospection.java:178)
at agent.introspection.servlet.ServletIntrospectionWrapper.registerFilter(ServletIntrospectionWrapper.java:188)
at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java)
at com.amazonaws.serverless.proxy.internal.servlet.FilterHolder.init(FilterHolder.java:89)
at com.amazonaws.serverless.proxy.internal.servlet.FilterChainHolder.doFilter(FilterChainHolder.java:86)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at com.amazonaws.serverless.proxy.internal.servlet.FilterChainHolder.doFilter(FilterChainHolder.java:90)
at com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler.doFilter(AwsLambdaServletContainerHandler.java:156)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:180)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.handleRequest(SpringBootLambdaContainerHandler.java:53)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxy(LambdaContainerHandler.java:211)
at com.amazonaws.serverless.proxy.internal.LambdaContainerHandler.proxyStream(LambdaContainerHandler.java:254)
at <censored>
at <censored>
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at lambdainternal.HandlerInfo.fromString(HandlerInfo.java:33)
at lambdainternal.AWSLambda.findUserMethods(AWSLambda.java:109)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:230)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:199)
at lambdainternal.AWSLambda.main(AWSLambda.java:193)
Caused by: java.lang.UnsupportedOperationException
at com.amazonaws.serverless.proxy.internal.servlet.AwsServletContext.getServletContextName(AwsServletContext.java:314)
... 28 more
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. I'm afraid there a several places where this library doesn't comply with the Spec as we are not offering a full servlet container.
However in this case returning null should be fine.
To help us debug your issue fill in the basic information below using the options provided
Serverless Java Container version:
1.6
Implementations:
Core
Framework version:
SpringBoot 2 v1.7-SNAPSHOT
Frontend service:
HTTP API
Deployment method:
SAM
Scenario
I'm trying to instrument an AWS Lambda function with a Java agent containing a Servlet instrumentation. In the instrumentation of
Filter#init(FilterConfig)
, the agent callsgetServletContext()
(via reflection) on theFilterConfig
, which returns acom.amazonaws.serverless.proxy.internal.servlet.AwsServletContext
object. Then, again via reflection, the agent callsgetServletContextName()
.Expected behavior
getServletContextName()
returns a name ornull
as per the Servlet spec:https://javaee.github.io/javaee-spec/javadocs/javax/servlet/ServletContext.html#getServletContextName--
Actual behavior
getServletContextName()
throws anUnsupportedOperationException
(wrapped in anInvocationTargetException
due to reflection).Steps to reproduce
getServletContextName()
on it.Log output
Not the full logs since they're not relevant, but here's the
InvocationTargetException
i got when discovering this issue:The text was updated successfully, but these errors were encountered: