服務(wù)器報錯日志如下:
Caused by: feign.codec.DecodeException: Error while extracting response for type [class com.sunyard.sany.ccb.resp.BusinessStatusResp] and content type [application/json;charset=utf-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
通過比對發(fā)現(xiàn),wiremock會自動在heard頭添加如下參數(shù)
'Matched-Stub-Id': 'da9ac487-02e8-4ef1-ba4b-9bfe01c68504', 'Vary': 'Accept-Encoding, User-Agent', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked'
引起報錯的正是:?'Content-Encoding': 'gzip'
服務(wù)器不改代碼澳化,能正確解析的寫法
{
? ? ? ? "request":{
? ? ? ? ? ? ? ? "urlPattern":"/test/status.*",
? ? ? ? ? ? ? ? "bodyPatterns":[{"matchesJsonPath":"$[?(@.test== 'ttttt')]"}]
? ? ? ? },
? ? ? ? "response":{
? ? ? ? ? ? ? ? "status":200,
? ? ? ? ? ? ? ? "jsonBody" : {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "code": "0",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "message": "成功",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "status": "2"
? ? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? "headers" : {
? ? ? ? ? ? ? ? ? ? ? ? "Content-Type" : "application/json;charset=utf-8",
? ? ? ? ? ? ? ? ? ? ? ? "Content-Encoding":""
? ? ? ? ? ? ? ? }
? ? ? ? }
}
解決過程中,看到的其他解決辦法(未驗證)