springcloud微服务调用报错

时间:2024-04-01 18:46:11

报错信息如下

Caused by: com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
 at [Source: (PushbackInputStream); line: 1, column: 2]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1851)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:707)
	at com.fasterxml.jackson.core.base.ParserMinimalBase._throwInvalidSpace(ParserMinimalBase.java:685)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:3007)
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:719)
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4662)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4511)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3519)
	at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:273)
	... 58 common frames omitted

原因

Illegal character ((CTRL-CHAR, code 31))的问题是因为聚合层往核心层进行过feign调用时参数过大,经过网络传输到达后端服务时数据丢失导致解析失败。所以接下来调整聚合层的feign的压缩配置:

feign.compression.request.min-request-size = 2048

该参数配置改大即可