Permalink
Browse files

EntityStreams: added the capability to all the Throwable, in particul…

…ar the unchecked "Error"s

TestEntityStream: refactored the tests to check for both RuntimeException and Error thrown inside the handlers

RB=912675
BUG=SI-3319
G=si-core-reviewers
R=ssheng,jodzga,ssodhani
A=jodzga
  • Loading branch information...
1 parent c032ec4 commit e72930a00df96479a5813edaff1be04a7f2a0b95 fcapponi committed Feb 7, 2017
@@ -8,6 +8,7 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+
;
/**
@@ -108,12 +109,12 @@ public void setReader(Reader r)
}
final WriteHandle wh = new WriteHandleImpl();
- RuntimeException writerInitEx = null;
+ Throwable writerInitEx = null;
try
{
_writer.onInit(wh);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Writer throws exception at onInit", ex);
synchronized (_lock)
@@ -236,7 +237,7 @@ public void write(final ByteString data)
{
observer.onDataAvailable(data);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Observer throws exception at onDataAvailable", ex);
}
@@ -246,7 +247,7 @@ public void write(final ByteString data)
{
_reader.onDataAvailable(data);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Reader throws exception at onDataAvailable", ex);
@@ -296,7 +297,7 @@ public void done()
{
observer.onDone();
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Observer throws exception at onDone, ignored.", ex);
}
@@ -306,7 +307,7 @@ public void done()
{
_reader.onDone();
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Reader throws exception at onDone; notifying writer", ex);
// At this point, no cancel had happened and no cancel will happen, _writer.onAbort will not be invoked more than once
@@ -349,7 +350,7 @@ public void error(final Throwable e)
{
_reader.onError(e);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Reader throws exception at onError; notifying writer", ex);
// at this point, no cancel had happened and no cancel will happen, _writer.onAbort will not be invoked more than once
@@ -435,7 +436,7 @@ public void request(final int chunkNum)
{
_writer.onWritePossible();
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Writer throws at onWritePossible", ex);
// we can safely do cancel here as no WriteHandle method could be called at the same time
@@ -490,7 +491,7 @@ private void safeAbortWriter(Throwable throwable)
{
_writer.onAbort(throwable);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Writer throws exception at onAbort", ex);
}
@@ -504,7 +505,7 @@ private void safeNotifyErrorToObservers(Throwable throwable)
{
observer.onError(throwable);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.warn("Observer throws exception at onError, ignored.", ex);
}
@@ -517,7 +518,7 @@ private void safeNotifyErrorToReader(Throwable throwable)
{
_reader.onError(throwable);
}
- catch (RuntimeException ex)
+ catch (Throwable ex)
{
LOG.error("Reader throws exception at onError", ex);
}
Oops, something went wrong.

0 comments on commit e72930a

Please sign in to comment.