Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)
Los mantenedores suelen responder en 1 día
@VelpulaGangavardhan ya está trabajando en esto.
Desde el 16/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend, observability
Línea de trabajo
El matcher está en apm-agent-plugins/apm-spring-webmvc/apm-spring-webmvc-spring5/src/main/java/co/elastic/apm/agent/springwebmvc/ViewRenderInstrumentation.java, en getMethodMatcher(), y beforeExecute() muestra por qué se requiere la instancia. Lee ambos y luego añade pruebas de regresión para un subtipo de View con una sobrecarga estática de render de cuatro argumentos y para el renderizado normal de instancia con tres argumentos. Se considera terminado cuando la sobrecarga estática se carga sin error de transformación, la ruta de instancia sigue creando su span y las excepciones siguen cerrando el span.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Elastic APM Java agent 1.57.0 fails to transform EasyPOI's cn.afterturn.easypoi.view.PoiBaseView. Its Spring MVC View instrumentation also matches a static four-argument render overload, but the advice requires an instance (@Advice.This).
Observed warning:
WARN co.elastic.apm.agent.bci.bytebuddy.ErrorLoggingListener - Error on transformation cn.afterturn.easypoi.view.PoiBaseView
java.lang.IllegalStateException: Cannot map this reference for static method or constructor start:
public static void cn.afterturn.easypoi.view.PoiBaseView.render(java.util.Map,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.String)
The application continues starting, but this class transformation fails. The failure happens during instrumentation; an invocation of the static helper is not necessary to explain the binding error.
Relevant versions: Java 8; Spring Framework 4.3.20.RELEASE; Elastic APM Java agent 1.57.0.
Steps to reproduce
The following synthetic class illustrates the affected method shape without requiring EasyPOI. This standalone reproduction has not yet been independently executed; the reported warning above was observed with PoiBaseView.
package example;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.view.AbstractView;
public abstract class OverloadedView extends AbstractView {
public static void render(Map<String, ?> model,
HttpServletRequest request,
HttpServletResponse response,
String viewName) {
// A convenience overload, not the View instance method.
}
}
- Include Spring MVC and the Servlet API, compile this class, and start with agent 1.57.0 and
spring-view-renderenabled. - Load the class, for example with
Class.forName("example.OverloadedView"). - The type matches because it implements Spring's
ViewthroughAbstractView. Its static overload also matches the current method matcher, causing@Advice.Thisbinding to fail.
EasyPOI's public implementation has the same signature: PoiBaseView source.
Expected behavior
Only the intended non-static, three-argument View.render(Map, HttpServletRequest, HttpServletResponse) implementation should receive this advice. Static convenience overloads should be ignored, and normal Spring MVC View rendering should remain instrumented.
Source analysis
The same matcher is present in main at commit 5cabf9ceeaea99f7a811b896064bf7aa8b131e5d (source inspected; that commit was not runtime-tested):
getMethodMatcher()checks the namerenderand the first three argument types, but does not constrain the argument count or exclude static methods.beforeExecuterequires@Advice.Thisand uses the instance to determine the span subtype.
A possible fix is to add not(isStatic()) and takesArguments(3) to the matcher, preserving the existing javax/jakarta argument checks. Suggested regression coverage:
- A View subtype with the static four-argument overload above loads without a transformation error.
- Normal three-argument instance rendering still produces the expected span.
- Exceptions during normal rendering still close the span correctly.
This differs from #2896, which fixes a null View name rather than binding instance advice to a static method.
Workaround
Exclude cn.afterturn.easypoi.view.PoiBaseView using classes_excluded_from_instrumentation, or disable spring-view-render if losing all Spring View rendering spans is acceptable. HTTP request tracing can remain enabled separately.
- Lenguaje dominante
- Java
- Estrellas
- 593
- Forks
- 338
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de elastic/apm-agent-java
-
agent-java
Dificultad 2/5 1-2 días Aptitud para principiantes 62/100
elastic/apm-agent-java#2844 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Improve docs and add error log related to illegal activation of transactionPosiblemente ocupada @AzazelSensei la tomó hace 41 días. Abiertodocs good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
elastic/apm-agent-java#850 · 4 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Log4j 2.7 log correlation calls ThreadContext.removeAll, which was introduced in 2.8Posiblemente ocupada @Anshuman-Prakash la tomó hace 1 día. Abiertoagent-java community triage
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
elastic/apm-agent-java#4593 ·
Los mantenedores suelen responder en 1 día
-
agent-java community triage
elastic/apm-agent-java#4573 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
agent-java
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
elastic/apm-agent-java#4549 ·
Los mantenedores suelen responder en 1 día
Todos los issues de elastic/apm-agent-java
Issues similares
-
status: waiting-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
spring-projects/spring-ai#7206 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
eclipse-dirigible/dirigible#7958 ·
Los mantenedores suelen responder en 1 día
-
bug ci sev-6
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
-
area/cli
Dificultad 2/5 Medio día Aptitud para principiantes 78/100
quarkusio/quarkus#57623 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
jhipster/prettier-java#1113 ·
Los mantenedores suelen responder en 2 días