@Test public void release() { mockStatic(IoUtil.class); new BaseByteArrayWriter(dataWriter, posWriter, lenWriter, true, lastPosWriter, lastPosReader).release(); verifyZeroInteractions(lastPosWriter); verifyStatic(IoUtil.class); IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); new BaseByteArrayWriter(dataWriter, posWriter, lenWriter, false, lastPosWriter, lastPosReader).release(); verify(lastPosWriter).put(0, 0); verifyStatic(IoUtil.class, times(2)); IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); doThrow(new RuntimeException()).when(lastPosWriter).put(0, 0); try { new BaseByteArrayWriter(dataWriter, posWriter, lenWriter, false, lastPosWriter, lastPosReader).release(); } catch (Exception ignore) { } verify(lastPosWriter, times(2)).put(0, 0); verifyStatic(IoUtil.class, times(3)); IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); }
@Override public void release() { try { if (!isOverwrite) { lastPosWriter.put(0, curPos); } } finally { IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); } }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void release() { try { if (!isOverwrite) { lastPosWriter.put(0, curPos); } } finally { IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); } } }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void release() { try { if (!isOverwrite) { lastPosWriter.put(0, curPos); } } finally { IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); } } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void release() { try { if (!isOverwrite) { lastPosWriter.put(0, curPos); } } finally { IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); } } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); @Override void put(long pos, byte[] val); @Override OutputStream putStream(final long pos); @Override void resetContentPosition(); @Override void release(); }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void release() { try { if (!isOverwrite) { lastPosWriter.put(0, curPos); } } finally { IoUtil.release(lastPosWriter, dataWriter, posWriter, lenWriter); } } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); @Override void put(long pos, byte[] val); @Override OutputStream putStream(final long pos); @Override void resetContentPosition(); @Override void release();  }