spring-cloud / spring-cloud/spring-cloud-function

FunctionInvocationWrapper.wrapped flag never resets when a function invocation throws

Abierto Apto para principiantes
#1,384 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Java
Estrellas
1.1k
Forks
641
Merge medio
11 h 2 min
PR fusionados (30 d)
8

Descripción

Bug

In SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), the FunctionInvocationWrapper.wrapped flag is set to true before delegating to doApply() (to prevent re-entrant wrapping). It is reset to false afterwards — but not in a finally block:

Object result = this.doApply(input, targetFunction);
targetFunction.wrapped = false; // ← skipped if doApply throws
return result;

When a function invocation throws, wrapped stays true forever. Every subsequent message finds wrapped = true and bypasses the ObservationFunctionAroundWrapper entirely.

This means ObservationFunctionAroundWrapper — and therefore the spring_cloud_function_seconds Micrometer timer — only records the very first message invocation which leads to an error. Every subsequent message bypasses the observation entirely.

Symptom

spring_cloud_function_seconds_count with an error is permanently stuck at 1 regardless of how many more messages result in an error. Confirmed with OTLP cumulative temporality (default), no pod restarts.

Expected behaviour

spring_cloud_function_seconds_count increments on every function invocation which leads to an error.

Actual behaviour

spring_cloud_function_seconds_count is always 1 after the first invocation which led to an error — further invocations are not observed.

Versions

  • spring-cloud-function-context:4.3.0
  • Also confirmed present in main branch (same lines 622–623 in SimpleFunctionRegistry.java)

Suggested fix

Reset this.wrapped = false after the wrapper call returns, e.g. in a finally block:

    this.wrapped = true;
    try {
        result = functionAroundWrapper.apply(input, this);
    }
    finally {
        this.wrapped = false;
    }
}

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Comienza en SimpleFunctionRegistry.java, en SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), especialmente en el reset envolvente alrededor de doApply(). Sigue la ruta del error y la interacción con ObservationFunctionAroundWrapper. Se considera terminado cuando las invocaciones fallidas repetidas continúan observándose y spring_cloud_function_seconds_count se incrementa por cada error.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
observability
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Tranquilo
Claridad
Bien especificado
Aptitud para principiantes
76/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.