Skip to content

fix: isolate per-lookup output content type from the cached function wrapper - #1557

Closed
mvanhorn wants to merge 1 commit into
spring-cloud:mainfrom
mvanhorn:fix/1534-function-lookup-shared-wrapper
Closed

mvanhorn wants to merge 1 commit into
spring-cloud:mainfrom
mvanhorn:fix/1534-function-lookup-shared-wrapper

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Background

A caller requesting JSON could receive plain text if another caller looked up the same function before the first caller invoked it. A caller that specified no output format could also inherit an earlier caller's choice.

SimpleFunctionRegistry.doLookup stored the requested MIME types on the cached singleton wrapper. Each lookup that supplied MIME types overwrote the shared field, and a lookup that omitted them left the previous value in place.

Summary of the fix

A singleton lookup that specifies output MIME types now returns a separate FunctionInvocationWrapper with those types. The wrapper reuses the same target, preserves composition, conversion, and header settings, and has its own invocation state. Lookups without MIME types still return the cached singleton wrapper. Regression tests cover concurrent lookups, isolation of conversion settings, and JSON output from a composed function.

Verification

  • Ran mvnw locally for the spring-cloud-function SimpleFunctionRegistry change; it passed.
  • The tests passed with the spring-cloud-function SimpleFunctionRegistry change applied; a run with it reverted gave no clear result, so no test is shown to catch this bug.
  • The changed test spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistryTests.java did not run here: no test runner for it was available.

Resolves #1534

…wrapper

A singleton lookup that specifies output MIME types now returns a
separate FunctionInvocationWrapper with those types. The wrapper reuses
the same target, preserves composition, conversion, and header settings,
and has its own invocation state. Lookups without MIME types still
return the cached singleton wrapper. Regression tests cover concurrent
lookups, isolation of conversion settings, and JSON output from a
composed function.

Fixes spring-cloud#1534

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@olegz

olegz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Merged to main as 35c9100 (commit message amended to start with GH-1534; authorship and your Signed-off-by are preserved). Thank you for the fix and the regression tests!

@olegz olegz closed this in 35c9100 Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function lookup with an expected output content type modifies the shared cached function wrapper

2 participants