You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/05/25 12:37:00 UTC

[jira] [Commented] (OFBIZ-12621) Json response failed when element not serializable

    [ https://issues.apache.org/jira/browse/OFBIZ-12621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17542030#comment-17542030 ] 

ASF subversion and git services commented on OFBIZ-12621:
---------------------------------------------------------

Commit 82f25f619228cf50a3a7a2e6726e24b3cc94298d in ofbiz-framework's branch refs/heads/trunk from Nicolas Malin
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=82f25f6192 ]

Fixed: Json response failed when element not serializable (OFBIZ-12621)

When you forward a request-map on json response after a service call like this :

     <request-map uri="updateMyEntity">
        <security https="true" auth="true"/>
        <event type="service" invoke="serviceWithUnserializableElement"/>
        <response name="success" type="request" value="json"/>
        <response name="error" type="request" value="json"/>
    </request-map>

The request json works fine if the serviceWithUnserializableElement have an element unserializable on out put at the first level

     <service name="serviceWithUnserializableElement"...>
        <attribute name="outputStream" type="java.io.OutputStream" mode="OUT"/>
     </service>

If the definition is like this

     <service name="serviceWithUnserializableElement"...>
        <attribute name="outputStreamMap" type="Map" mode="OUT"/>
     </service>

The json failed to generate if the outputStream is a map. despite the function UtilHttp.getJSONAttributeMap that safe only the first map level and don't work in deep.

By the way, we improved the getJSONAttributeMap to work in deep by a recursive treatment on Map and List.


> Json response failed when element not serializable
> --------------------------------------------------
>
>                 Key: OFBIZ-12621
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-12621
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework/webapp
>    Affects Versions: 22.01.01, Upcoming Branch
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Major
>              Labels: json, webapp
>         Attachments: OFBIZ-12621.patch
>
>
> When you forward a request-map on json response after a service call like this :
>  
> {code:java}
>      <request-map uri="updateMyEntity">
>         <security https="true" auth="true"/>
>         <event type="service" invoke="serviceWithUnserializableElement"/>
>         <response name="success" type="request" value="json"/>
>         <response name="error" type="request" value="json"/>
>     </request-map>
> {code}
> The request json works fine if the serviceWithUnserializableElement have an element unserializable on out put at the first level
> {code:java}
>      <service name="serviceWithUnserializableElement"...>
>         <attribute name="outputStream" type="java.io.OutputStream" mode="OUT"/>
>     </service>
> {code}
> If the definition is like this 
> {code:java}
>      <service name="serviceWithUnserializableElement"...>
>         <attribute name="outputStreamMap" type="Map" mode="OUT"/>
>     </service>{code}
> The json failed to generate if the outputStream is a map en
> try here :
> {code:java}
> CommonEvents.jsonResponseFromRequestAttributes:
>             JSON json = JSON.from(attrMap);
>             writeJSONtoResponse(json, request, response);
> {code}
> Despite the function UtilHttp.getJSONAttributeMap that safe only the first map level and don't work in deep.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)