@SuppressWarnings("resource") // Explicitly closed in try block, and TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb);
private TemporaryBuffer doMerge(MergeResult<RawText> result) throws IOException { TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile( db != null ? nonNullRepo().getDirectory() : null, inCoreLimit); try { new MergeFormatter().formatMerge(buf, result, Arrays.asList(commitNames), UTF_8); buf.close(); } catch (IOException e) { buf.destroy(); throw e; } return buf; }
@Override public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; try (FileInputStream in = new FileInputStream(onDiskFile)) { IO.readFully(in, out, 0, (int) len); } return out; }
@SuppressWarnings("resource") // Explicitly closed in try block, and TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb);
TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20); try { tree.write(tmp, bb);
if (filterCommand != null) { if (FilterCommandRegistry.isRegistered(filterCommand)) { LocalFile buffer = new TemporaryBuffer.LocalFile(null); FilterCommand command = FilterCommandRegistry .createFilterCommand(filterCommand, repository, in, return buffer.openInputStreamWithAutoDestroy();
/** * Run the LFS clean filter on the given stream and return a stream to the * LFS pointer file buffer. Used when inserting objects. * * @param db * the {@link Repository} * @param originalContent * the {@link InputStream} to the original content * @return a {@link TemporaryBuffer} representing the LFS pointer. The * caller is responsible to destroy the buffer. * @throws IOException * in case of any error. */ public static TemporaryBuffer cleanLfsBlob(Repository db, InputStream originalContent) throws IOException { LocalFile buffer = new TemporaryBuffer.LocalFile(null); CleanFilter f = new CleanFilter(db, originalContent, buffer); try { while (f.run() != -1) { // loop as long as f.run() tells there is work to do } } catch (IOException e) { buffer.destroy(); throw e; } return buffer; }
/** * Execute a command defined by a {@link ProcessBuilder}. * * @param pb * The command to be executed * @param in * The standard input stream passed to the process * @return The result of the executed command * @throws InterruptedException * @throws IOException * @since 4.2 */ public ExecutionResult execute(ProcessBuilder pb, InputStream in) throws IOException, InterruptedException { TemporaryBuffer stdout = new TemporaryBuffer.LocalFile(null); TemporaryBuffer stderr = new TemporaryBuffer.Heap(1024, 1024 * 1024); try { int rc = runProcess(pb, stdout, stderr, in); return new ExecutionResult(stdout, stderr, rc); } finally { stdout.close(); stderr.close(); } }
/** * Execute a command defined by a {@link java.lang.ProcessBuilder}. * * @param pb * The command to be executed * @param in * The standard input stream passed to the process * @return The result of the executed command * @throws java.lang.InterruptedException * @throws java.io.IOException * @since 4.2 */ public ExecutionResult execute(ProcessBuilder pb, InputStream in) throws IOException, InterruptedException { try (TemporaryBuffer stdout = new TemporaryBuffer.LocalFile(null); TemporaryBuffer stderr = new TemporaryBuffer.Heap(1024, 1024 * 1024)) { int rc = runProcess(pb, stdout, stderr, in); return new ExecutionResult(stdout, stderr, rc); } }
public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; final FileInputStream in = new FileInputStream(onDiskFile); try { IO.readFully(in, out, 0, (int) len); } finally { in.close(); } return out; }
@Override public byte[] toByteArray() throws IOException { if (onDiskFile == null) { return super.toByteArray(); } final long len = length(); if (Integer.MAX_VALUE < len) throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize); final byte[] out = new byte[(int) len]; try (FileInputStream in = new FileInputStream(onDiskFile)) { IO.readFully(in, out, 0, (int) len); } return out; }
private ObjectId insertMergeResult(MergeResult<RawText> result) throws IOException { TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile( db.getDirectory(), 10 << 20); try { new MergeFormatter().formatMerge(buf, result, Arrays.asList(commitNames), CHARACTER_ENCODING); buf.close(); try (InputStream in = buf.openInputStream()) { return getObjectInserter().insert(OBJ_BLOB, buf.length(), in); } } finally { buf.destroy(); } }
public void setFixedLengthStreamingMode(int contentLength) { if (entity != null) throw new IllegalArgumentException(); entity = new TemporaryBufferEntity(new TemporaryBuffer.LocalFile(null)); entity.setContentLength(contentLength); }
@Override public void close() throws IOException { super.close(); destroy(); } };
public OutputStream getOutputStream() throws IOException { if (entity == null) entity = new TemporaryBufferEntity(new TemporaryBuffer.LocalFile(null)); return entity.getBuffer(); }
public OutputStream getOutputStream() throws IOException { if (entity == null) entity = new TemporaryBufferEntity(new LocalFile()); return entity.getBuffer(); }
public void setFixedLengthStreamingMode(int contentLength) { if (entity != null) throw new IllegalArgumentException(); entity = new TemporaryBufferEntity(new LocalFile()); entity.setContentLength(contentLength); }
public void setFixedLengthStreamingMode(int contentLength) { if (entity != null) throw new IllegalArgumentException(); entity = new TemporaryBufferEntity(new LocalFile(null)); entity.setContentLength(contentLength); }
public void setChunkedStreamingMode(int chunklen) { if (entity == null) entity = new TemporaryBufferEntity(new LocalFile()); entity.setChunked(true); }
/** {@inheritDoc} */ @Override public OutputStream getOutputStream() throws IOException { if (entity == null) entity = new TemporaryBufferEntity(new LocalFile(null)); return entity.getBuffer(); }