From 7bd13e741b57327d83c3bf25e9e9093fa6351bbe Mon Sep 17 00:00:00 2001 From: Greg Watson Date: Mon, 27 Jan 2014 18:15:05 -0500 Subject: [PATCH] Don't buffer files in memory. Signed-off-by: Greg Watson --- .../core/commands/GetInputStreamCommand.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/commands/GetInputStreamCommand.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/commands/GetInputStreamCommand.java index 99b00e60076..25114ba540d 100644 --- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/commands/GetInputStreamCommand.java +++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/commands/GetInputStreamCommand.java @@ -1,7 +1,5 @@ package org.eclipse.remote.internal.jsch.core.commands; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -10,7 +8,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.remote.core.exception.RemoteConnectionException; import org.eclipse.remote.internal.jsch.core.JSchConnection; -import org.eclipse.remote.internal.jsch.core.messages.Messages; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.SftpException; @@ -26,19 +23,19 @@ public class GetInputStreamCommand extends AbstractRemoteCommand { @Override public InputStream getResult(IProgressMonitor monitor) throws RemoteConnectionException { final SubMonitor subMon = SubMonitor.convert(monitor, 10); - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - SftpCallable c = new SftpCallable() { + SftpCallable c = new SftpCallable() { @Override - public Void call() throws JSchException, SftpException, IOException { - getChannel().get(fRemotePath.toString(), out, new CommandProgressMonitor(getProgressMonitor())); - out.close(); - return null; + public InputStream call() throws JSchException, SftpException, IOException { + try { + return getConnection().getSftpChannel().get(fRemotePath.toString(), + new CommandProgressMonitor(getProgressMonitor())); + } catch (RemoteConnectionException e) { + throw new IOException(e.getMessage()); + } } }; try { - subMon.subTask(Messages.GetInputStreamCommand_Get_input_stream); - c.getResult(subMon.newChild(10)); - return new ByteArrayInputStream(out.toByteArray()); + return c.getResult(subMon.newChild(10)); } catch (SftpException e) { throw new RemoteConnectionException(e.getMessage()); }