Skip to content

Commit

Permalink
[RESTEASY-2620]:Doesn't close stream for Publisher return
Browse files Browse the repository at this point in the history
  • Loading branch information
jimma authored and asoldano committed Oct 27, 2020
1 parent eea6c41 commit a05aebb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.jboss.resteasy.spi.util.Types;
import org.jboss.resteasy.tracing.RESTEasyTracingLogger;
import org.jboss.resteasy.util.DelegatingOutputStream;
import org.reactivestreams.Publisher;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
Expand Down Expand Up @@ -162,7 +163,7 @@ public static <T> T extractResult(GenericType<T> responseType, Response response
{
T rtn = response.readEntity(responseType, annotations);
if (InputStream.class.isInstance(rtn) || Reader.class.isInstance(rtn)
|| EventInput.class.isInstance(rtn))
|| EventInput.class.isInstance(rtn) || Publisher.class.isInstance(rtn))
{
if (response instanceof ClientResponse)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import org.jboss.resteasy.client.jaxrs.i18n.Messages;
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation;
import org.jboss.resteasy.client.jaxrs.internal.ClientResponse;
import org.jboss.resteasy.plugins.providers.sse.EventInput;
import org.jboss.resteasy.spi.util.Types;
import org.reactivestreams.Publisher;

import javax.ws.rs.core.GenericType;

Expand Down Expand Up @@ -60,7 +62,7 @@ public Object extractEntity(ClientContext context, Object... args)
gt = new GenericType(method.getReturnType());
}
Object obj = ClientInvocation.extractResult(gt, response, method.getAnnotations());
if (obj instanceof InputStream || obj instanceof Reader)
if (obj instanceof InputStream || obj instanceof Reader || obj instanceof Publisher || obj instanceof EventInput)
releaseConnectionAfter = false;
return obj;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import org.jboss.resteasy.spi.util.Types;
import org.jboss.resteasy.util.InputStreamToByteArray;
import org.jboss.resteasy.util.ReadFromStream;
import org.reactivestreams.Publisher;

import javax.ws.rs.ProcessingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ReaderInterceptor;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -93,7 +95,7 @@ else if (bufferedEntity == null)
{
try
{
if (!EventInput.class.isInstance(entity))
if (!Publisher.class.isInstance(entity) && !EventInput.class.isInstance(entity))
{
close();
}
Expand Down

0 comments on commit a05aebb

Please sign in to comment.