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

FunctionInvocationWrapper.wrapped flag never resets when a function invocation throws

オープン 初心者向け
#1,384 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
1.1k
フォーク
641
平均マージ
11時間 2分
マージ済み PR(30日)
8

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

SimpleFunctionRegistry.java の SimpleFunctionRegistry.FunctionInvocationWrapper.apply() から始め、特に doApply() を囲む reset を確認してください。エラーパスと ObservationFunctionAroundWrapper との相互作用を追跡してください。繰り返し失敗する呼び出しが引き続き観測され、エラーごとに spring_cloud_function_seconds_count がインクリメントされれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
observability
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
76/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。