FunctionInvocationWrapper.wrapped flag never resets when a function invocation throws
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- java
- Domain
- observability
Research direction
Start in SimpleFunctionRegistry.java at SimpleFunctionRegistry.FunctionInvocationWrapper.apply(), especially the wrapped reset around doApply(). Trace the error path and the ObservationFunctionAroundWrapper interaction. Done means repeated failing invocations continue to be observed and spring_cloud_function_seconds_count increments for each error.
Written by the indexing model from the issue text.
Description
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
mainbranch (same lines 622–623 inSimpleFunctionRegistry.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;
}
}
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 641
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-cloud/spring-cloud-function
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spring-cloud/spring-cloud-function#1455 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
spring-cloud/spring-cloud-function#1325 · 3 comments · 2 reactions ·
All issues in spring-cloud/spring-cloud-function
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100