#6670·shenyu

[BUG] — `AiResponseTransformerPlugin`: `new ObjectMapper()` per response (two sites)

Author: Aias00Created Aug 3, 2026Updated Sep 19, 2026
Labelsfeature: plugintype: performancepriority: high
  • severity: High
  • files: shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/.../AiResponseTransformerPlugin.java:220 (new ObjectMapper().readTree(body) inside extractJsonBodyFromAiResponse, per response) and :337 (ObjectMapper objectMapper = new ObjectMapper() inside writeWith's flatMap, per response)
  • description: writeWith runs on every decorated response body when the ai-response-transformer plugin is active; new ObjectMapper() builds a fresh TypeFactory/SerializerProvider each call. Sibling AiTokenLimiterPlugin.java:196 correctly hoists a static MAPPER.
  • impact: Per-response ObjectMapper construction on every AI-transformed response; CPU + young-gen pressure under load.
  • suggested_fix: Hoist private static final ObjectMapper MAPPER = new ObjectMapper(); (reuse sibling pattern).
  • confidence: High
  • related_existing: PERF-22 covers McpServerPlugin.java:710 + MessageHandlingResult.java:93; these are different files/classes.

Identified during the 2026-08-02 deep re-scan; full list in docs/scan2-2026-08-02/00-consolidated-critical-high.md.