Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E097ED221 for ; Mon, 16 Jul 2012 15:47:40 +0000 (UTC) Received: (qmail 94556 invoked by uid 500); 16 Jul 2012 15:47:40 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 94266 invoked by uid 500); 16 Jul 2012 15:47:40 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 94246 invoked by uid 99); 16 Jul 2012 15:47:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 15:47:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 15:47:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1760E23889DE for ; Mon, 16 Jul 2012 15:47:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1362105 - /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java Date: Mon, 16 Jul 2012 15:47:19 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120716154719.1760E23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Mon Jul 16 15:47:18 2012 New Revision: 1362105 URL: http://svn.apache.org/viewvc?rev=1362105&view=rev Log: Checkstyle fixes. Formatting. Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java?rev=1362105&r1=1362104&r2=1362105&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java Mon Jul 16 15:47:18 2012 @@ -39,16 +39,19 @@ public class SftpFileSystem extends AbstractFileSystem implements FileSystem { - private static final long LAST_MOD_TIME_ACCURACY = 1000L; private Session session; + // private final JSch jSch; + private ChannelSftp idleChannel; + /** * Cache for the user ID (-1 when not set) */ private int uid = -1; + /** * Cache for the user groups ids (null when not set) */ @@ -84,7 +87,6 @@ public class SftpFileSystem protected ChannelSftp getChannel() throws IOException { ensureSession(); - try { // Use the pooled channel, or create a new one @@ -98,7 +100,6 @@ public class SftpFileSystem { channel = (ChannelSftp) session.openChannel("sftp"); channel.connect(); - Boolean userDirIsRoot = SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions()); String workingDirectory = getRootName().getPath(); @@ -115,14 +116,11 @@ public class SftpFileSystem } } } - return channel; } catch (final JSchException e) { - throw new FileSystemException("vfs.provider.sftp/connect.error", - getRootName(), - e); + throw new FileSystemException("vfs.provider.sftp/connect.error", getRootName(), e); } } @@ -156,15 +154,12 @@ public class SftpFileSystem } catch (final Exception e) { - throw new FileSystemException("vfs.provider.sftp/connect.error", - getRootName(), - e); + throw new FileSystemException("vfs.provider.sftp/connect.error", getRootName(), e); } finally { UserAuthenticatorUtils.cleanup(authData); } - this.session = session; } } @@ -229,7 +224,6 @@ public class SftpFileSystem { if (groupsIds == null) { - StringBuilder output = new StringBuilder(); int code = executeCommand("id -G", output); if (code != 0) @@ -243,7 +237,6 @@ public class SftpFileSystem groupsIds[i] = Integer.parseInt(groups[i]); this.groupsIds = groupsIds; - } return groupsIds; } @@ -259,11 +252,11 @@ public class SftpFileSystem { if (uid < 0) { - StringBuilder output = new StringBuilder(); int code = executeCommand("id -u", output); - if (code != 0) + if (code != 0) { throw new JSchException("Could not get the user id of the current user (error code: " + code + ")"); + } uid = Integer.parseInt(output.toString().trim()); } return uid; @@ -299,12 +292,17 @@ public class SftpFileSystem stream.close(); // Wait until the command finishes (should not be long since we read the output stream) - while (!channel.isClosed()) { - try{Thread.sleep(100);} catch(Exception ee){} + while (!channel.isClosed()) + { + try + { + Thread.sleep(100); + } catch (Exception ee) + { + // TODO: swallow exception, really? + } } - channel.disconnect(); - return channel.getExitStatus(); } }