Added onReadFailure() callback to allow subclasses to perform actions
in case of read failures.
This commit is contained in:
parent
43454ebd0a
commit
a1d18a157d
|
@ -102,6 +102,16 @@ public class InputStreamContentProvider implements ContentProvider
|
||||||
return ByteBuffer.wrap(buffer, offset, length);
|
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
|
@Override
|
||||||
public Iterator<ByteBuffer> iterator()
|
public Iterator<ByteBuffer> iterator()
|
||||||
{
|
{
|
||||||
|
@ -166,6 +176,7 @@ public class InputStreamContentProvider implements ContentProvider
|
||||||
if (failure == null)
|
if (failure == null)
|
||||||
{
|
{
|
||||||
failure = x;
|
failure = x;
|
||||||
|
onReadFailure(x);
|
||||||
// Signal we have more content to cause a call to
|
// Signal we have more content to cause a call to
|
||||||
// next() which will throw NoSuchElementException.
|
// next() which will throw NoSuchElementException.
|
||||||
hasNext = Boolean.TRUE;
|
hasNext = Boolean.TRUE;
|
||||||
|
|
Loading…
Reference in New Issue