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

未關閉
#1,534 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
backend

研究方向

Start in SimpleFunctionRegistry.doLookup(..) and the wrappedFunctionDefinitions cache it reads from, listing every mutable per-lookup field on the wrapper (expectedOutputContentType, skipInputConversion, skipOutputConversion, the input header enhancer, propagateInputHeaders). Then trace where the invocation applies those settings to see whether they can be passed per call instead of stored. The fix is done when a new test looks up one function concurrently with different expected content types and each result keeps its own, with existing registry tests still green.

由索引模型根據 Issue 內容生成。

描述

5.0.x backport bug

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.

主要語言
Java
星號
1.1k
分支
655
平均合併
4 小時 54 分鐘
30 天內合併 PR
10

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

spring-cloud/spring-cloud-function 的其他 Issue

查看 spring-cloud/spring-cloud-function 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。