I have encountered an issue when I receive an response from another controller.
Workflow ->
Controller A (http://localhost:8081/) will send request to Controller B *(http://localhost:8082/) *to some endpoint and eventually Controller B, after working on some business logic will return the response back to Controller A.
So now, when I hit one endpoint : /validate in Controller B from Controller A. I am receiving an exception across line (This patch of code is in Controller A):
responseNode = restTemplate
.exchange(builder.buildAndExpand().toUri(), HttpMethod.GET, requestEntity, JsonNode.class)
.getBody();
Where
builder.buildAndExpand().toUri()
forms proper endpoint URI (i.e. http://localhost:8082/validate) , requestEntity is headers and responseNode is in JsonNode
format.
Exception caused ::
com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 2]
We are receiving Response 200 OK across Controller A, from Controller B. And this is next debug logger Reading to [com.fasterxml.jackson.databind.JsonNode]
Basically we are receiving boolean as a response in Controller B's /validate API, so I dont get why this showing us an error like this across Controller A.
Seems, like it is not able to convert / transalate, I am unable to understand here. Any help on this is highly thankful and Thanks in advance.
I tried to use Object
object instead of JsonNode
for the responseNode obj, unfortunately this issue persisted. I also checked this questtion in stack overflow: https://stackoverflow.com/questions/42621547/jackson-error-illegal-character-only-regular-white-space-allowed-when-parsi, but the answers were informational, but not helpful for my case.