apache / apache/servicecomb-java-chassis
Jackson在处理字符串时存在长度限制,是否可以添加配置项,供业务控制其所能解析的字符传长度?
- 主要語言
- Java
- 星號
- 1.9k
- 分支
- 814
- 平均合併
- 8 天 23 小時
- 30 天內合併 PR
- 1
描述
当前遇到一个问题,是服务端返回的响应消息中,字符串长度过长,导致jackson解析失败
```
Caused by: com.fasterxml.jackson.core.exc.StreamConstraintsException: String length (20051112) exceeds the maximum length (20000000)
at com.fasterxml...core.StreamReadConstraints.validateStringLength:324
at com.fasterxml...util.ReadConstrainedTextBuffer.validateStringLength:27
at com.fasterxml...util.TextBuffer.finishCurrentSegment:939
at com.fasterxml...json.UTF8StreamJsonParser._finishString2:2584
at com.fasterxml...json.UTF8StreamJsonParser._finishAndReturnString:2560
at com.fasterxml...json.UTF8StreamJsonParser.getText:335
at com.fasterxml...jsonorg.JSONObjectDeserializer.deserialize:51
at com.fasterxml...jsonorg.JSONObjectDeserializer.deserialize:48
at com.fasterxml...jsonorg.JSONObjectDeserializer.deserialize:14
at com.fasterxml...deser.DefaultDeserializationContext.readRootValue:323
at com.fasterxml...databind.ObjectMapper._readMapAndClose:4825mas
at com.fasterxml...databind.ObjectMapper.readValue:3825
at org.apache...produce.ProduceJsonProcessor.doDecodeResponse:64
at org.apache...produce.ProduceProcessor.decodeResponse:76
at org.apache...http.DefaultHttpClientFilter.extractResponse:105
at org.apache...http.DefaultHttpClientFilter.afterReceiveResponse:139
at org.apache...http.RestClientInvocation.lambda$processResponseBody$7:251
```
20000000是jackson提供的默认值;从chassis源码中来看,并没有提供配置该长度的配置项,是否可以加一个
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
追蹤從 ProduceJsonProcessor.doDecodeResponse 經過 ProduceProcessor.decodeResponse 到 DefaultHttpClientFilter.extractResponse 的回應解碼流程,著重於 Jackson 的 StreamReadConstraints 對字串長度的驗證。確認可以在哪裡設定服務層級的最大字串長度,然後驗證在解碼超大型回應時會遵守已設定的限制。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- api, backend
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100