Question

I am relatively new to Wink and trying to debug a defect in which a POJO that contains a byte array is [I think] being improperly serialized into json for the response. By improperly I mean that I have unicode characters stored as a blob that have been extracted into the byte array and when the byte array is serialized into json, it is being decoded as something other than the UTF-8 characters the unicode bytes should represent.

In trying to trace this problem, I've validated that the bytes look as I expect them to up to the point where they are returned from my request resource. My @GET request resource method returns a List. I understand from reading the guide that

  1. RequestHandler chain is executed and ultimately invokes my resource method...
  2. The return from the resource method (@GET in this case) is supposed to go into the messagecontext which is passed to the ResponseHandler chain, I think...

My concern is that the contents of the pojo returned by my resource method, which contains a byte[], is not being serialized correctly and is producing invalid json content which is being sent to the user. How does my returned List get into the messageContext?

I am unable to attach a debugger to the machine running this application.

Was it helpful?

Solution

I partially answered my question. The object returned from a resource method is attached to the MessageContext object's responseEntity property. I assume messageContext.setResponseEntity() is invoked by org.apache.wink.server.handlers.RequestHandler.InvokeMethodHandler but haven't verified this.

I still have to figure out why, when my byte[] is serialized into json that it is not assuming the UTF-8 encoding (and subsequently mangling my special characters)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top