@Test(expected = IllegalStateException.class) public void start_afterStart() { stream.start(listener); stream.start(mock(ClientStreamListener.class)); }
@Override public void start(ClientStreamListener listener) { checkState(this.listener == null, "already started"); Status savedError; boolean savedPassThrough; synchronized (this) { this.listener = checkNotNull(listener, "listener"); savedError = error; savedPassThrough = passThrough; if (!savedPassThrough) { listener = delayedListener = new DelayedStreamListener(listener); } } if (savedError != null) { listener.closed(savedError, new Metadata()); return; } if (savedPassThrough) { realStream.start(listener); } else { final ClientStreamListener finalListener = listener; delayOrExecute(new Runnable() { @Override public void run() { realStream.start(finalListener); } }); } }
DelayedStream implements ClientStream { @Override public void start(ClientStreamListener listener) { checkState(this.listener == null, "already started"); Status savedError; boolean savedPassThrough; synchronized (this) { this.listener = checkNotNull(listener, "listener"); savedError = error; savedPassThrough = passThrough; if (!savedPassThrough) { listener = delayedListener = new DelayedStreamListener(listener); } } if (savedError != null) { listener.closed(savedError, new Metadata()); return; } if (savedPassThrough) { realStream.start(listener); } else { final ClientStreamListener finalListener = listener; delayOrExecute(new Runnable() { @Override public void run() { realStream.start(finalListener); } }); } } }
DelayedStream implements ClientStream { @Override public void start(ClientStreamListener listener) { checkState(this.listener == null, "already started"); Status savedError; boolean savedPassThrough; synchronized (this) { this.listener = checkNotNull(listener, "listener"); savedError = error; savedPassThrough = passThrough; if (!savedPassThrough) { listener = delayedListener = new DelayedStreamListener(listener); } } if (savedError != null) { listener.closed(savedError, new Metadata()); return; } if (savedPassThrough) { realStream.start(listener); } else { final ClientStreamListener finalListener = listener; delayOrExecute(new Runnable() { @Override public void run() { realStream.start(finalListener); } }); } }  }
DelayedStream implements ClientStream { @Override public void start(ClientStreamListener listener) { checkState(this.listener == null, "already started"); Status savedError; boolean savedPassThrough; synchronized (this) { this.listener = checkNotNull(listener, "listener"); savedError = error; savedPassThrough = passThrough; if (!savedPassThrough) { listener = delayedListener = new DelayedStreamListener(listener); } } if (savedError != null) { listener.closed(savedError, new Metadata()); return; } if (savedPassThrough) { realStream.start(listener); } else { final ClientStreamListener finalListener = listener; delayOrExecute(new Runnable() { @Override public void run() { realStream.start(finalListener); } }); } }  @Override void setMaxInboundMessageSize(final int maxSize); @Override void setMaxOutboundMessageSize(final int maxSize); @Override void setDeadline(final Deadline deadline); @Override void setAuthority(final String authority); @Override void start(ClientStreamListener listener); @Override Attributes getAttributes(); @Override void writeMessage(final InputStream message); @Override void flush(); @Override void cancel(final Status reason); @Override void halfClose(); @Override void request(final int numMessages); @Override void setCompressor(final Compressor compressor); @Override void setFullStreamDecompression(final boolean fullStreamDecompression); @Override void setDecompressorRegistry(final DecompressorRegistry decompressorRegistry); @Override boolean isReady(); @Override void setMessageCompression(final boolean enable); }
DelayedStream implements ClientStream { @Override public void start(ClientStreamListener listener) { checkState(this.listener == null, "already started"); Status savedError; boolean savedPassThrough; synchronized (this) { this.listener = checkNotNull(listener, "listener"); savedError = error; savedPassThrough = passThrough; if (!savedPassThrough) { listener = delayedListener = new DelayedStreamListener(listener); } } if (savedError != null) { listener.closed(savedError, new Metadata()); return; } if (savedPassThrough) { realStream.start(listener); } else { final ClientStreamListener finalListener = listener; delayOrExecute(new Runnable() { @Override public void run() { realStream.start(finalListener); } }); } }  @Override void setMaxInboundMessageSize(final int maxSize); @Override void setMaxOutboundMessageSize(final int maxSize); @Override void setDeadline(final Deadline deadline); @Override void setAuthority(final String authority); @Override void start(ClientStreamListener listener); @Override Attributes getAttributes(); @Override void writeMessage(final InputStream message); @Override void flush(); @Override void cancel(final Status reason); @Override void halfClose(); @Override void request(final int numMessages); @Override void setCompressor(final Compressor compressor); @Override void setFullStreamDecompression(final boolean fullStreamDecompression); @Override void setDecompressorRegistry(final DecompressorRegistry decompressorRegistry); @Override boolean isReady(); @Override void setMessageCompression(final boolean enable);  }