From a1d18a157da2a1e7addd559743a40a7cbd1043a0 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 2 May 2014 22:45:56 +0200 Subject: [PATCH] Added onReadFailure() callback to allow subclasses to perform actions in case of read failures. --- .../jetty/client/util/InputStreamContentProvider.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamContentProvider.java b/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamContentProvider.java index bd0606530d4..89d3022ae27 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamContentProvider.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/util/InputStreamContentProvider.java @@ -102,6 +102,16 @@ public class InputStreamContentProvider implements ContentProvider return ByteBuffer.wrap(buffer, offset, length); } + /** + * Callback method invoked when an exception is thrown while reading + * from the stream. + * + * @param failure the exception thrown while reading from the stream. + */ + protected void onReadFailure(Throwable failure) + { + } + @Override public Iterator iterator() { @@ -166,6 +176,7 @@ public class InputStreamContentProvider implements ContentProvider if (failure == null) { failure = x; + onReadFailure(x); // Signal we have more content to cause a call to // next() which will throw NoSuchElementException. hasNext = Boolean.TRUE;