### Question:
BufferDrainer { public int drainBuffers() throws IOException { if (drainBuffersFinished) { throw new IllegalStateException("Buffer draining has already been finished"); } LOG.trace("drainBuffers() start"); int exitValue = -1; int inBytesRead = 0; int errBytesRead = 0; boolean processEnded = false; try (final BufferedReader ir = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); final BufferedReader er = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))) { while (!processEnded) { try { exitValue = process.exitValue(); processEnded = true; } catch (final IllegalThreadStateException itse) { } inBytesRead += drainBuffer(ir, inputBuffer, maxLength, inBytesRead, processEnded); errBytesRead += drainBuffer(er, errorBuffer, maxLength, errBytesRead, processEnded); if (!processEnded) { try { LOG.trace("Sleeping {}ms during buffer draining", DRAIN_BUFFER_SLEEP_TIME_MS); Thread.sleep(DRAIN_BUFFER_SLEEP_TIME_MS); } catch (final InterruptedException ie) { } } } } LOG.trace("drainBuffers() end [exitValue={0}]", exitValue); drainBuffersFinished = true; return exitValue; } BufferDrainer(Process process, int maxLength); int drainBuffers(); StringBuffer getInputBuffer(); StringBuffer getErrorBuffer();  }### Answer:
@Test public void testMultipleDrainBufferCalls() throws IOException { Process process = BlockingWritesExitValueProcess.createFastWritingProcess("", ""); final BufferDrainer bufferDrainer = new BufferDrainer(process, 0); bufferDrainer.drainBuffers(); expectedException.expect(IllegalStateException.class); bufferDrainer.drainBuffers(); }