You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2019/07/31 13:27:23 UTC
[cxf] branch 3.2.x-fixes updated: [CXF-8081]should cache reactor
OutputStream
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
new bccd134 [CXF-8081]should cache reactor OutputStream
bccd134 is described below
commit bccd1342c19c09bfce0b7ba43957f069407a192d
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Tue Jul 30 19:10:09 2019 -0400
[CXF-8081]should cache reactor OutputStream
(cherry picked from commit 60f0e66fbfe2df15e35e67594f8a0350f17a9691)
---
.../jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java | 6 ++++++
.../java/org/apache/cxf/systest/jaxrs/reactor/ReactorServer.java | 3 ---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 1ea8c0c..c30360f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -90,6 +90,7 @@ import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CacheAndWriteOutputStream;
import org.apache.cxf.io.ReaderInputStream;
import org.apache.cxf.jaxrs.JAXRSServiceImpl;
import org.apache.cxf.jaxrs.ext.ContextProvider;
@@ -1411,6 +1412,11 @@ public final class JAXRSUtils {
throws WebApplicationException, IOException {
OutputStream entityStream = message.getContent(OutputStream.class);
+ if (entity.getClass().getName().equals("org.apache.cxf.jaxrs.reactivestreams.server.StreamingAsyncSubscriber$StreamingResponseImpl")) {
+ //cache the OutputStream when it's reactive response
+ entityStream = new CacheAndWriteOutputStream(entityStream);
+ }
+
if (writers.size() > 1) {
WriterInterceptor first = writers.remove(0);
WriterInterceptorContext context = new WriterInterceptorContextImpl(entity,
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactor/ReactorServer.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactor/ReactorServer.java
index 0d7fe27..88de2ab 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactor/ReactorServer.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactor/ReactorServer.java
@@ -23,7 +23,6 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
import org.apache.cxf.jaxrs.reactor.server.ReactorCustomizer;
@@ -44,7 +43,6 @@ public class ReactorServer extends AbstractBusTestServerBase {
sf.getProperties(true).put("useStreamingSubscriber", false);
sf.setProvider(new JacksonJsonProvider());
new ReactorCustomizer().customize(sf);
- sf.getOutInterceptors().add(new LoggingOutInterceptor());
sf.setResourceClasses(FluxService.class, MonoService.class);
sf.setResourceProvider(FluxService.class,
new SingletonResourceProvider(new FluxService(), true));
@@ -57,7 +55,6 @@ public class ReactorServer extends AbstractBusTestServerBase {
sf2.setProvider(new JacksonJsonProvider());
sf2.setProvider(new IllegalArgumentExceptionMapper());
new ReactorCustomizer().customize(sf2);
- sf2.getOutInterceptors().add(new LoggingOutInterceptor());
sf2.setResourceClasses(FluxService.class);
sf2.setResourceProvider(FluxService.class,
new SingletonResourceProvider(new FluxService(), true));