cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1518556 - /cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
Date Thu, 29 Aug 2013 09:56:15 GMT
Author: sergeyb
Date: Thu Aug 29 09:56:15 2013
New Revision: 1518556

URL: http://svn.apache.org/r1518556
Log:
[CXF-5240] Fixing JSONP out interceptor to check message OutputStream first, thanks to Vadim
Beilin

Modified:
    cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java

Modified: cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java?rev=1518556&r1=1518555&r2=1518556&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
(original)
+++ cxf/trunk/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/jsonp/AbstractJsonpOutInterceptor.java
Thu Aug 29 09:56:15 2013
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.provider.jsonp;
 
 import java.io.IOException;
+import java.io.OutputStream;
 
 import javax.servlet.http.HttpServletResponse;
 
@@ -40,12 +41,20 @@ public abstract class AbstractJsonpOutIn
     }
     
     protected void writeValue(Message message, String value) throws Fault {
-        HttpServletResponse response = (HttpServletResponse) message.get("HTTP.RESPONSE");
         try {
-            response.getOutputStream().write(value.getBytes("UTF-8"));
+            getOutputStream(message).write(value.getBytes("UTF-8"));
         } catch (IOException e) {
             throw new Fault(e);
         }
     }
+    
+    private OutputStream getOutputStream(Message message) throws IOException {
+        OutputStream os = message.getContent(OutputStream.class);
+        if (os == null) {
+            HttpServletResponse response = (HttpServletResponse) message.get("HTTP.RESPONSE");
+            os = response.getOutputStream();
+        }
+        return os;
+    }
 
 }



Mime
View raw message