I have a client that consumes an input stream from a service, like this:
@Client(value = 'http://localhost:8080/')
interface StreamClient {
@Get(uri = '/data', processes = MediaType.APPLICATION_OCTET_STREAM)
@Header("Accept: application/octet-stream")
Flowable<byte[]> retrieveFile()
}
and when using it like this (Groovy):
void getContent(OutputStream outputStream) {
client.retrieveFile().blockingSubscribe({ byte[] bytes ->
outputStream.write(bytes)
}, { Throwable error ->
error.printStackTrace()
})
}
it retrieves the stream just fine without reading the entire byte[]
array into memory (exactly as I want it), but if the endpoint returns a 404, I just get an empty byte array, not an error as I would expect.
What am I doing wrong?