[jira] [Commented] (SLING-6948) HttpServletResponse.getOutput() and getOutputAsStream() return different information

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SLING-6948) HttpServletResponse.getOutput() and getOutputAsStream() return different information

JIRA jira@apache.org

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

Robert Munteanu commented on SLING-6948:
----------------------------------------

{code}diff --git a/bundles/extensions/servlet-helpers/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletResponseTest.java b/bundles/extensions/servlet-helpers/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletResponseTest.java
index 3f72e15f0d..4e1ab73f6e 100644
--- a/bundles/extensions/servlet-helpers/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletResponseTest.java
+++ b/bundles/extensions/servlet-helpers/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletResponseTest.java
@@ -133,6 +133,7 @@ public class MockSlingHttpServletResponseTest {
         final String TEST_CONTENT = "Der Jodelkaiser äöü߀ ᚠᛇᚻ";
         response.setCharacterEncoding(CharEncoding.UTF_8);
         response.getWriter().write(TEST_CONTENT);
+        assertEquals(TEST_CONTENT, new String(response.getOutput(), CharEncoding.UTF_8));
         assertEquals(TEST_CONTENT, response.getOutputAsString());
 
         response.resetBuffer();
{code}

Note that ordering is important, adding the line after the existing {{assertEquals}} call does not trigger the error.

> HttpServletResponse.getOutput() and getOutputAsStream() return different information
> ------------------------------------------------------------------------------------
>
>                 Key: SLING-6948
>                 URL: https://issues.apache.org/jira/browse/SLING-6948
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Servlet Helpers 1.1.0
>            Reporter: Robert Munteanu
>
> HttpServletResponse.getOutput and getOutputAsString are backed by ResponseBodySupport. That class holds both a ServletOutputStream and a PrintWriter, which are not kept in sync. getOutput uses the ServletOutputStream and getOutputAsString uses the PrintWriter.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)