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

Đang mở
#1,534 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
1.1k
Fork
655
Merge trung bình
4 giờ 54 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của spring-cloud/spring-cloud-function

Tất cả issue của spring-cloud/spring-cloud-function

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.