@Test public void testCommandToStreamingWithNoHeader() throws Exception { HystrixCommand<InputStream> command = new CommandHelperTestCommand(); final StreamingResponseBody responseBody = CommandHelper.toStreaming(command); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); responseBody.writeTo(outputStream); assertEquals("test", new String(outputStream.toByteArray())); }
public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) { return outputStream -> { final Observable<InputStream> stream = command.toObservable(); stream.toBlocking().subscribe(inputStream -> { try { IOUtils.copyLarge(inputStream, outputStream); outputStream.flush(); } catch (IOException e) { try { inputStream.close(); } catch (IOException closingException) { LOGGER.warn("could not close command result, a http connection may be leaked !", closingException); } LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e); } }, TDPException::rethrowOrWrap); }; }
CommandHelper { public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) { return outputStream -> { final Observable<InputStream> stream = command.toObservable(); stream.toBlocking().subscribe(inputStream -> { try { IOUtils.copyLarge(inputStream, outputStream); outputStream.flush(); } catch (IOException e) { try { inputStream.close(); } catch (IOException closingException) { LOGGER.warn("could not close command result, a http connection may be leaked !", closingException); } LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e); } }, TDPException::rethrowOrWrap); }; } }
CommandHelper { public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) { return outputStream -> { final Observable<InputStream> stream = command.toObservable(); stream.toBlocking().subscribe(inputStream -> { try { IOUtils.copyLarge(inputStream, outputStream); outputStream.flush(); } catch (IOException e) { try { inputStream.close(); } catch (IOException closingException) { LOGGER.warn("could not close command result, a http connection may be leaked !", closingException); } LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e); } }, TDPException::rethrowOrWrap); }; } private  CommandHelper(); }
CommandHelper { public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) { return outputStream -> { final Observable<InputStream> stream = command.toObservable(); stream.toBlocking().subscribe(inputStream -> { try { IOUtils.copyLarge(inputStream, outputStream); outputStream.flush(); } catch (IOException e) { try { inputStream.close(); } catch (IOException closingException) { LOGGER.warn("could not close command result, a http connection may be leaked !", closingException); } LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e); } }, TDPException::rethrowOrWrap); }; } private  CommandHelper(); static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command); static ResponseEntity<Void> async(final GenericCommand<?> command); static ResponseEntity<StreamingResponseBody> toStreaming(final GenericCommand<InputStream> command); static Publisher<T> toPublisher(final Class<T> clazz, final ObjectMapper mapper,
            final HystrixCommand<InputStream> command); static Stream<T> toStream(Class<T> clazz, ObjectMapper mapper, HystrixCommand<InputStream> command); }
CommandHelper { public static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command) { return outputStream -> { final Observable<InputStream> stream = command.toObservable(); stream.toBlocking().subscribe(inputStream -> { try { IOUtils.copyLarge(inputStream, outputStream); outputStream.flush(); } catch (IOException e) { try { inputStream.close(); } catch (IOException closingException) { LOGGER.warn("could not close command result, a http connection may be leaked !", closingException); } LOGGER.error("Unable to fully copy command result '{}'.", command.getClass(), e); } }, TDPException::rethrowOrWrap); }; } private  CommandHelper(); static StreamingResponseBody toStreaming(final HystrixCommand<InputStream> command); static ResponseEntity<Void> async(final GenericCommand<?> command); static ResponseEntity<StreamingResponseBody> toStreaming(final GenericCommand<InputStream> command); static Publisher<T> toPublisher(final Class<T> clazz, final ObjectMapper mapper,
            final HystrixCommand<InputStream> command); static Stream<T> toStream(Class<T> clazz, ObjectMapper mapper, HystrixCommand<InputStream> command);  }