I'm overriding FilterClient so I can see incoming requests. I'd like some way to get a String representation of the ActionRequest that's passed in. ActionRequest let's you write to a StreamOuput, which is an Elasticsearch type that is a subclass of OutputStream. This SO post shows how to convert OutputStream to a String, but I'm forced to use StreamOuput due to the FilterClient API.
How do I get a String representation of ActionRequest or at least a readable version that will show me useful information about the request? (Calling ActionRequest.toString calls Object.toString, which is not good enough for me.)
StreamOutput is an abstract class which has a subclass called OutputStreamStreamOutput. The latter is basically a wrapper around an OutputStream, so you'd create an instance that wraps a ByteArrayOutputStream and then use it in the ActionRequest.writeTo() call.
// in your override doExecute method, add this:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos);
request.writeTo(osso);
String requestAsString = baos.toString("UTF-8");
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With