org.springframework.core.codec.DecodingException : JSON 디코딩 오류 : 잘못된 문자 ((CTRL-CHAR, 코드 31))

Aug 26 2020

WebClient (org.springframework.web.reactive.function.client)를 통해 게시 메서드의 응답을받는 다음 오류가 발생합니다.

org.springframework.core.codec.DecodingException: JSON decoding 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
at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 2]
at org.springframework.http.codec.json.AbstractJackson2Decoder.processException(AbstractJackson2Decoder.java:215)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Ȁ

실패 로 요청의 헤더를 변경하려고 시도 했습니다 .

headers.put("Accept-Encoding", "gzip");

또는

headers.put("Accept-Encoding", "identity");

웹 클라이언트가 어떤 이유로 든 gzip으로 압축 된 응답을 처리 할 수없는 것입니까 !!

미리 감사드립니다 !!

답변

1 Nilotpal Aug 28 2020 at 02:48

응답 개체에 Serializable을 구현하지 못했습니다.

PrasanthRajendran Nov 12 2020 at 13:53

나는 봄 부팅의 체하다 의존성이 예외를 받기 시작했다 spring-cloud-openfeign-core나는 버전으로 업그레이드 할 때 spring-cloud-openfeign-core까지를 2.2.5.RELEASE.

버전 2.2.5.RELEASE 또는 이후 버전으로 업그레이드하는 경우 이미 속성이있는 경우이 문제가 발생합니다 feign.request.compression=true.

기술적 인 이유는 FeignContentGzipEncodingAutoConfiguration클래스에서 조건부 속성 주석 서명이에서 @ConditionalOnProperty("feign.compression.request.enabled", matchIfMissing = false)로 변경 @ConditionalOnProperty(value = "feign.compression.request.enabled")되어 기본적 FeignContentGzipEncodingInterceptor으로 트리거 되기 때문 입니다. GitHub 참조

해결 방법

처리 할 메커니즘이없는 스프링 부트 서비스를 호출하는 경우 compressed request아래 속성을 사용하여 가짜 요청 압축을 비활성화하십시오.

feign.request.compression=false.

참고 : 안타깝게도 압축 된 요청 참조 를 처리 할 수있는 기본 제공 솔루션이 아직 없습니다.