Skip to content

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

Done

Description

@olegz

SimpleFunctionRegistry.doLookup(..) assigns the requested output mime types to the wrapper it returns (function.expectedOutputContentType = expectedOutputMimeTypes). That wrapper is usually the instance cached in wrappedFunctionDefinitions and shared by all callers, because functions are singletons by default.

This has two consequences:

  • concurrent lookups of the same function definition with different expected content types (for example HTTP requests with different Accept headers) overwrite each other's value on one shared, non-volatile field, so a request may be converted to the content type that another request asked for
  • the field is only assigned when mime types are given and is never reset, so a later lookup without mime types still uses the content type left by an earlier caller

The wrapper holds other per-lookup state with the same problem: skipInputConversion, skipOutputConversion, the input header enhancer and propagateInputHeaders.

Proposed change: do not modify the cached wrapper. Return a lightweight per-lookup view or copy when a lookup needs different settings (or pass the expected content type with the invocation), and add a test that looks up the same function concurrently with different content types and verifies that each result uses its own.

Activity

  1. added this to the 5.1.1 milestone on Nov 23, 2026
  2. mvanhorn commented on Nov 25, 2026

    @mvanhorn
    Contributor

    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.

    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.

    #1557

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions