sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SLING-8047) Rendered/exported JSON requested via SlingRequestProcessor is not written to output stream
Date Wed, 31 Oct 2018 07:23:00 GMT

     [ https://issues.apache.org/jira/browse/SLING-8047?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Carsten Ziegeler updated SLING-8047:
------------------------------------
    Component/s:     (was: Feature Model)

> Rendered/exported JSON requested via SlingRequestProcessor is not written to output stream
> ------------------------------------------------------------------------------------------
>
>                 Key: SLING-8047
>                 URL: https://issues.apache.org/jira/browse/SLING-8047
>             Project: Sling
>          Issue Type: Bug
>          Components: Servlets
>            Reporter: Philip Mundt
>            Assignee: Jason E Bailey
>            Priority: Major
>         Attachments: SLING-8047-DefaultGetServlet-does-not-write-to-output-stream.patch,
SLING-8047-ExportServlet-does-not-write-to-output-stream.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> While trying to facilitate the {{SlingRequestProcessor}} to get a rendered or exported
JSON representation of a resource, we ran into the problem of the response always being empty.
The HTML rendering worked without any issue.
> (See example code of [Get the rendered HTML for an AEM resource, component or page|http://www.nateyolles.com/blog/2015/10/get-rendered-html-for-an-aem-resource-or-component]
or [https://stackoverflow.com/a/34218708])
> Main, observed difference seem to be the method calls to print writer:
> h4. JsonRenderer
> {{org.apache.sling.servlets.get.impl.helpers.JsonRenderer#render}} uses {{#write}} method
of response's print writer.
> h4. ExportServlet (via JacksonExporter)
> {{org.apache.sling.models.impl.ExportServlet#doGet}} uses {{#write}} method of response's
print writer.
> h4. HTMLRenderer
> {{org.apache.sling.servlets.get.impl.helpers.HtmlRenderer#render}} uses {{#print}} and
{{#println}} methods of response's print writer.
> h3. Further observations
> When the print writer's {{autoFlush}} property is set to true and one uses the {{#println}}
method instead of {{#write}}, the {{JsonRenderer}} will flush the print writer's buffer to
the output stream. Due to wrapping the response in {{org.apache.sling.scripting.core.impl.helper.OnDemandWriterResponse}}
(where {{autoFlush=false}}) this does not work for the {{ExportServlet}}.
> When adding implicit {{#flush()}} calls to both classes, both request scenarios will
work. According to the servlet specification, it should not be necessary to flush the print
writer, as the container must immediately flush all remaining content to the client upon "termination
of the service method of the servlet".
> Please find two test cases for (where implicit {{#flush()}} calls were added):
>  * JsonRenderer ({{sling-org-apache-sling-servlets-get}}): [^SLING-8047-DefaultGetServlet-does-not-write-to-output-stream.patch]
>  * ExportServlet ({{sling-org-apache-sling-models-impl}}): [^SLING-8047-ExportServlet-does-not-write-to-output-stream.patch]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message