BoundedInputStream in = new BoundedInputStream(fin, size)) {
@Override public ArjArchiveEntry getNextEntry() throws IOException { if (currentInputStream != null) { // return value ignored as IOUtils.skip ensures the stream is drained completely IOUtils.skip(currentInputStream, Long.MAX_VALUE); currentInputStream.close(); currentLocalFileHeader = null; currentInputStream = null; } currentLocalFileHeader = readLocalFileHeader(); if (currentLocalFileHeader != null) { currentInputStream = new BoundedInputStream(in, currentLocalFileHeader.compressedSize); if (currentLocalFileHeader.method == LocalFileHeader.Methods.STORED) { currentInputStream = new CRC32VerifyingInputStream(currentInputStream, currentLocalFileHeader.originalSize, currentLocalFileHeader.originalCrc32); } return new ArjArchiveEntry(currentLocalFileHeader); } currentInputStream = null; return null; }
/** * Write the contents of this scatter stream to a target archive. * * @param target The archive to receive the contents of this {@link ScatterZipOutputStream}. * @throws IOException If writing fails */ public void writeTo(final ZipArchiveOutputStream target) throws IOException { backingStore.closeForWriting(); try (final InputStream data = backingStore.getInputStream()) { for (final CompressedEntry compressedEntry : items) { try (final BoundedInputStream rawStream = new BoundedInputStream(data, compressedEntry.compressedSize)) { target.addRawArchiveEntry(compressedEntry.transferToArchiveEntry(), rawStream); } } } }
InputStream fileStream = new BoundedInputStream(currentFolderInputStream, file.getSize()); if (file.getHasCrc()) { fileStream = new CRC32VerifyingInputStream(fileStream, file.getSize(), file.getCrcValue());
new SnappyCompressorInputStream(new BoundedInputStream(in, size), blockSize);
private void nextBlock() throws IOException { maybeFinishCurrentBlock(); long len = ByteUtils.fromLittleEndian(supplier, 4); boolean uncompressed = (len & UNCOMPRESSED_FLAG_MASK) != 0; int realLen = (int) (len & (~UNCOMPRESSED_FLAG_MASK)); if (realLen == 0) { verifyContentChecksum(); if (!decompressConcatenated) { endReached = true; } else { init(false); } return; } InputStream capped = new BoundedInputStream(in, realLen); if (expectBlockChecksum) { capped = new ChecksumCalculatingInputStream(blockHash, capped); } if (uncompressed) { inUncompressed = true; currentBlock = capped; } else { inUncompressed = false; BlockLZ4CompressorInputStream s = new BlockLZ4CompressorInputStream(capped); if (expectBlockDependency) { s.prefill(blockDependencyBuffer); } currentBlock = s; } }
@Override public T decode(InputStream inStream) throws IOException { DataInputStream in = new DataInputStream(inStream); int len = VarInt.decodeInt(in); if (len < 0) { throw new CoderException("Invalid encoded SolrDocument length: " + len); } JavaBinCodec codec = new JavaBinCodec(); return (T) codec.unmarshal(new BoundedInputStream(in, len)); }
@Override public ArjArchiveEntry getNextEntry() throws IOException { if (currentInputStream != null) { // return value ignored as IOUtils.skip ensures the stream is drained completely IOUtils.skip(currentInputStream, Long.MAX_VALUE); currentInputStream.close(); currentLocalFileHeader = null; currentInputStream = null; } currentLocalFileHeader = readLocalFileHeader(); if (currentLocalFileHeader != null) { currentInputStream = new BoundedInputStream(in, currentLocalFileHeader.compressedSize); if (currentLocalFileHeader.method == LocalFileHeader.Methods.STORED) { currentInputStream = new CRC32VerifyingInputStream(currentInputStream, currentLocalFileHeader.originalSize, currentLocalFileHeader.originalCrc32); } return new ArjArchiveEntry(currentLocalFileHeader); } currentInputStream = null; return null; }
BoundedInputStream in = new BoundedInputStream(fin, size)) {
/** * Write the contents of this scatter stream to a target archive. * * @param target The archive to receive the contents of this {@link ScatterZipOutputStream}. * @throws IOException If writing fails */ public void writeTo(final ZipArchiveOutputStream target) throws IOException { backingStore.closeForWriting(); try (final InputStream data = backingStore.getInputStream()) { for (final CompressedEntry compressedEntry : items) { try (final BoundedInputStream rawStream = new BoundedInputStream(data, compressedEntry.compressedSize)) { target.addRawArchiveEntry(compressedEntry.transferToArchiveEntry(), rawStream); } } } }
InputStream fileStream = new BoundedInputStream(currentFolderInputStream, file.getSize()); if (file.getHasCrc()) { fileStream = new CRC32VerifyingInputStream(fileStream, file.getSize(), file.getCrcValue());
new SnappyCompressorInputStream(new BoundedInputStream(in, size), blockSize);
private void nextBlock() throws IOException { maybeFinishCurrentBlock(); long len = ByteUtils.fromLittleEndian(supplier, 4); boolean uncompressed = (len & UNCOMPRESSED_FLAG_MASK) != 0; int realLen = (int) (len & (~UNCOMPRESSED_FLAG_MASK)); if (realLen == 0) { verifyContentChecksum(); if (!decompressConcatenated) { endReached = true; } else { init(false); } return; } InputStream capped = new BoundedInputStream(in, realLen); if (expectBlockChecksum) { capped = new ChecksumCalculatingInputStream(blockHash, capped); } if (uncompressed) { inUncompressed = true; currentBlock = capped; } else { inUncompressed = false; BlockLZ4CompressorInputStream s = new BlockLZ4CompressorInputStream(capped); if (expectBlockDependency) { s.prefill(blockDependencyBuffer); } currentBlock = s; } }