Skip to content

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

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

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

Conversation

@mvanhorn

Copy link
Copy Markdown

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>

This branch has not been deployed

No deployments
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

1 participant