@Test(expected = IOException.class) @Category(IntegrationTest.class) public void poolableIsReleasedOnIOException() throws Exception { doThrow(IOException.class).when(target).write(any(Writer.class), any(Server.class), any(Query.class), any(ImmutableList.class)); WriterPoolOutputWriter<WriterBasedOutputWriter> outputWriter = new WriterPoolOutputWriter<>(target, pool, new Timeout(1, SECONDS)); try { outputWriter.doWrite(dummyServer(), dummyQuery(), dummyResults()); } finally { verify(allocator, timeout(500)).deallocate(any(WriterPoolable.class)); } }
@Override public void doWrite(Server server, Query query, Iterable<Result> results) throws Exception { WriterPoolable writerPoolable = claimWriter(); try { target.write(writerPoolable.getWriter(), server, query, results); } catch (IOException ioe) { writerPoolable.invalidate(); throw ioe; } finally { writerPoolable.release(); } }
WriterPoolOutputWriter extends OutputWriterAdapter { @Override public void doWrite(Server server, Query query, Iterable<Result> results) throws Exception { WriterPoolable writerPoolable = claimWriter(); try { target.write(writerPoolable.getWriter(), server, query, results); } catch (IOException ioe) { writerPoolable.invalidate(); throw ioe; } finally { writerPoolable.release(); } } }
WriterPoolOutputWriter extends OutputWriterAdapter { @Override public void doWrite(Server server, Query query, Iterable<Result> results) throws Exception { WriterPoolable writerPoolable = claimWriter(); try { target.write(writerPoolable.getWriter(), server, query, results); } catch (IOException ioe) { writerPoolable.invalidate(); throw ioe; } finally { writerPoolable.release(); } } WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout);  WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout, @Nullable int socketTimeoutMs); }
WriterPoolOutputWriter extends OutputWriterAdapter { @Override public void doWrite(Server server, Query query, Iterable<Result> results) throws Exception { WriterPoolable writerPoolable = claimWriter(); try { target.write(writerPoolable.getWriter(), server, query, results); } catch (IOException ioe) { writerPoolable.invalidate(); throw ioe; } finally { writerPoolable.release(); } } WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout);  WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout, @Nullable int socketTimeoutMs); @Override void doWrite(Server server, Query query, Iterable<Result> results); @Override void close(); @VisibleForTesting int getSocketTimeoutMs(); @VisibleForTesting LifecycledPool<? extends WriterPoolable> getWriterPool(); }
WriterPoolOutputWriter extends OutputWriterAdapter { @Override public void doWrite(Server server, Query query, Iterable<Result> results) throws Exception { WriterPoolable writerPoolable = claimWriter(); try { target.write(writerPoolable.getWriter(), server, query, results); } catch (IOException ioe) { writerPoolable.invalidate(); throw ioe; } finally { writerPoolable.release(); } } WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout);  WriterPoolOutputWriter(@Nonnull T target, @Nonnull LifecycledPool<? extends WriterPoolable> writerPool, @Nonnull Timeout poolClaimTimeout, @Nullable int socketTimeoutMs); @Override void doWrite(Server server, Query query, Iterable<Result> results); @Override void close(); @VisibleForTesting int getSocketTimeoutMs(); @VisibleForTesting LifecycledPool<? extends WriterPoolable> getWriterPool();  }