Hi All, I am currently working on issue [1], which was observed in DSS. When a data service is invoked with "Accept": "application/json", it returns an error, if the resultant data contains a NULL value.
When debugging the code I found out that, this is happened, when processing (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true") in the org.apache.axis2.json.gson.GsonXMLStreamWriter. There was one attribute specifying that particular element is null and there were no child elements. While trying to serialize that element, JsonWriter throws the following exception "Caused by: java.lang.IllegalStateException: Dangling name: LastName at com.google.gson.stream.JsonWriter.close(JsonWriter.java:302)" In org.apache.axiom.om.impl.llom.OMElementImpl, it first do the OMSerializerUtil.serializeStartpart(this, writer); for the element, then try to do OMSerializerUtil.serializeChildren(this, writer, cache);, but this doesn't do anything as that particular node doesn't have any child. Finally it tries to OMSerializerUtil.serializeEndpart(writer);, and fails giving the above exceptions. Currently, GsonXMLStreamWriter, doesn't process XML attributes. So there is no way to identify this like scenario. So, I changed the GsonXMLStreamWriter to process attributes in this particular case (public void writeAttribute(String prefix, String namespaceURI, String localName, String value)). It checks whether given parameters are related to the "NULL" entry and then call jsonWriter.nullValue() to add a (null), which solved the issue. Appreciate your feedback and suggestions on this implementation. [1] https://wso2.org/jira/browse/DS-972 Thanks, *Jayanga Dissanayake* Senior Software Engineer WSO2 Inc. - http://wso2.com/ lean . enterprise . middleware email: jaya...@wso2.com mobile: +94772207259
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev