Aravind A - 2018-02-27

I am moving a project from JBOSS 6 EAP to Spring Boot. It looks like TextNode.getBinaryValue expects a Base64Encoded value but I am not sure how to bypass this. The issue occurs when there is an '' in the data in JsonNode. Can someone please help me wit this? Below is a mock code where I reproduced the issue. The JsonNode is dynamically generated an I will not be able to change this. All I need is the response to accept the '' and bypass the base64 encoding validation

@POST
@Consumes({ MediaType.TEXT_PLAIN })
@Produces({ MediaType.APPLICATION_JSON })
public Map<String,List<JsonNode>> echo(@NotEmpty String echoText) {
    Map<String,List<JsonNode>> map = new HashMap<>();
    List<JsonNode> jsonNodeList = new ArrayList<>();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode val = mapper.convertValue("TEST_DATA", JsonNode.class);
    jsonNodeList.add(val);
    map.put("Test", jsonNodeList);

    return map;
}

Below is the trace

16:51:27.036 [http-nio-8080-exec-7] ERROR org.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002025: Unknown exception while executing POST /echo/
org.codehaus.jackson.JsonParseException: Illegal character '_' (code 0x5f) in base64 content
 at [Source: N/A; line: -1, column: -1]
    at org.codehaus.jackson.node.TextNode._reportInvalidBase64(TextNode.java:291)
    at org.codehaus.jackson.node.TextNode._reportInvalidBase64(TextNode.java:267)
    at org.codehaus.jackson.node.TextNode.getBinaryValue(TextNode.java:83)
    at org.codehaus.jackson.node.TextNode.getBinaryValue(TextNode.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:664)
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:689)
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
    at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
    at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
    at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:633)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:536)
    at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:30)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:416)
    at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1425)
    at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:951)