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

FunctionInvocationWrapper.wrapped flag never resets when a function invocation throws

Offen Anfängerfreundlich
#1,384 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
1.1k
Forks
641
Ø Merge
11 Std. 2 Min.
Gemergte PRs (30 T.)
8

Beschreibung

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;
    }
}

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in SimpleFunctionRegistry.java bei SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), insbesondere beim umschließenden Reset um doApply(). Verfolge den Fehlerpfad und die Interaktion mit ObservationFunctionAroundWrapper. Als erledigt gilt die Aufgabe, wenn wiederholte fehlgeschlagene Aufrufe weiterhin beobachtet werden und spring_cloud_function_seconds_count für jeden Fehler inkrementiert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
observability
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
76/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.