Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)

Abierto Apto para principiantes
#4,594 1 comentario 0 reacciones 0 asignados Ver en GitHub

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
Stack tecnológico
java, spring

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

agent-java community triage

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.
    }
}
  1. Include Spring MVC and the Servlet API, compile this class, and start with agent 1.57.0 and spring-view-render enabled.
  2. Load the class, for example with Class.forName("example.OverloadedView").
  3. The type matches because it implements Spring's View through AbstractView. Its static overload also matches the current method matcher, causing @Advice.This binding 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 name render and the first three argument types, but does not constrain the argument count or exclude static methods.
  • beforeExecute requires @Advice.This and 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de elastic/apm-agent-java

Todos los issues de elastic/apm-agent-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.