}
// cleanup and exit immediately if in failure mode
// but here, throw an exception because this isn't supposed to happen
if (m_closed.get()) {
chunkC.discard();
IOException e = new IOException("Trying to write snapshot data " +
"after the stream is closed");
m_writeFailed.set(e);
return Futures.immediateFailedFuture(e);