Author: rgoers
Date: Fri Nov 6 17:47:05 2009
New Revision: 833493
URL:
http://svn.apache.org/viewvc?rev=833493&view=revLog:
keep in synch with trunk and fix a bug when no FileOptions are provided
Modified:
commons/proper/vfs/branches/VFS281/ (props changed)
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
commons/proper/vfs/branches/VFS281/pom.xml
commons/proper/vfs/branches/VFS281/xdocs/changes.xml
commons/proper/vfs/branches/VFS281/xdocs/testing.xml (props changed)
Propchange: commons/proper/vfs/branches/VFS281/
------------------------------------------------------------------------------
svn:mergeinfo = /commons/proper/vfs/trunk:812326-832523
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java Fri Nov 6 17:47:05 2009
@@ -31,6 +31,7 @@
import org.apache.commons.vfs.FilesCache;
import org.apache.commons.vfs.NameScope;
import org.apache.commons.vfs.VFS;
+import org.apache.commons.vfs.DefaultFileSystemOptions;
import org.apache.commons.vfs.cache.SoftRefFilesCache;
import org.apache.commons.vfs.operations.FileOperationProvider;
import org.apache.commons.vfs.provider.AbstractFileName;
@@ -645,8 +646,16 @@
public FileObject resolveFile(final FileObject baseFile, final String uri)
throws FileSystemException
{
- return resolveFile(baseFile, uri, baseFile == null ? null : baseFile
- .getFileSystem().getFileSystemOptions());
+ FileSystemOptions opts = null;
+ if (baseFile != null)
+ {
+ opts = baseFile.getFileSystem().getFileSystemOptions();
+ }
+ if (opts == null)
+ {
+ opts = new PrivateFileSystemOptions();
+ }
+ return resolveFile(baseFile, uri, opts);
}
/**
@@ -1185,4 +1194,8 @@
}
return (FileOperationProvider[]) providers.toArray(new FileOperationProvider[] {});
}
+
+ private class PrivateFileSystemOptions extends DefaultFileSystemOptions
+ {
+ }
}
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpClientFactory.java Fri Nov 6 17:47:05 2009
@@ -151,6 +151,12 @@
client.setDataTimeout(dataTimeout.intValue());
}
+ Integer socketTimeout = fileSystemOptions.getSoTimeout();
+ if (socketTimeout != null)
+ {
+ client.setSoTimeout(socketTimeout.intValue());
+ }
+
// Change to root by default
// All file operations a relative to the filesystem-root
// String root = getRoot().getName().getPath();
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java Fri Nov 6 17:47:05 2009
@@ -585,13 +585,19 @@
protected InputStream doGetInputStream() throws Exception
{
final FtpClient client = ftpFs.getClient();
- final InputStream instr = client.retrieveFileStream(relPath);
- // VFS-210
- if (instr == null)
- {
- throw new FileNotFoundException(getName().toString());
+ try {
+ final InputStream instr = client.retrieveFileStream(relPath);
+ // VFS-210
+ if (instr == null)
+ {
+ throw new FileNotFoundException(getName().toString());
+ }
+ return new FtpInputStream(client, instr);
+ }
+ catch (Exception e) {
+ ftpFs.putClient(client);
+ throw e;
}
- return new FtpInputStream(client, instr);
}
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
@@ -606,26 +612,32 @@
throws Exception
{
final FtpClient client = ftpFs.getClient();
- OutputStream out = null;
- if (bAppend)
- {
- out = client.appendFileStream(relPath);
- }
- else
- {
- out = client.storeFileStream(relPath);
- }
+ try {
+ OutputStream out = null;
+ if (bAppend)
+ {
+ out = client.appendFileStream(relPath);
+ }
+ else
+ {
+ out = client.storeFileStream(relPath);
+ }
- if (out == null)
- {
- throw new FileSystemException("vfs.provider.ftp/output-error.debug", new Object[]
- {
- this.getName(),
- client.getReplyString()
- });
- }
+ if (out == null)
+ {
+ throw new FileSystemException("vfs.provider.ftp/output-error.debug", new Object[]
+ {
+ this.getName(),
+ client.getReplyString()
+ });
+ }
- return new FtpOutputStream(client, out);
+ return new FtpOutputStream(client, out);
+ }
+ catch (Exception e) {
+ ftpFs.putClient(client);
+ throw e;
+ }
}
String getRelPath()
@@ -636,16 +648,22 @@
FtpInputStream getInputStream(long filePointer) throws IOException
{
final FtpClient client = ftpFs.getClient();
- final InputStream instr = client.retrieveFileStream(relPath, filePointer);
- if (instr == null)
- {
- throw new FileSystemException("vfs.provider.ftp/input-error.debug", new Object[]
- {
- this.getName(),
- client.getReplyString()
- });
+ try {
+ final InputStream instr = client.retrieveFileStream(relPath, filePointer);
+ if (instr == null)
+ {
+ throw new FileSystemException("vfs.provider.ftp/input-error.debug", new Object[]
+ {
+ this.getName(),
+ client.getReplyString()
+ });
+ }
+ return new FtpInputStream(client, instr);
+ }
+ catch (IOException e) {
+ ftpFs.putClient(client);
+ throw e;
}
- return new FtpInputStream(client, instr);
}
/**
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemConfigBuilder.java Fri Nov 6 17:47:05 2009
@@ -145,6 +145,27 @@
}
/**
+ * set the socket timeout for the ftp client.<br />
+ *
+ * @param opts The FileSystemOptions.
+ * @param soTimeout The timeout value.
+ */
+ public void setSoTimeout(FileSystemOptions opts, Integer soTimeout)
+ {
+ FtpFileSystemOptions.getInstance(opts).setDataTimeout(soTimeout);
+ }
+
+ /**
+ * @param opts The FileSystemOptions.
+ * @return The timeout as an Integer.
+ * @see #setDataTimeout
+ */
+ public Integer getSoTimeout(FileSystemOptions opts)
+ {
+ return FtpFileSystemOptions.getInstance(opts).getSoTimeout();
+ }
+
+ /**
* set the data timeout for the ftp client.<br />
* If you set the dataTimeout to <code>null</code> no dataTimeout will be set on the
* ftp client.
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemOptions.java Fri Nov 6 17:47:05 2009
@@ -31,6 +31,7 @@
private static final String PASSIVE_MODE = FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE";
private static final String USER_DIR_IS_ROOT = FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT";
private static final String DATA_TIMEOUT = FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT";
+ private final static String SO_TIMEOUT = FtpFileSystemConfigBuilder.class.getName() + ".SO_TIMEOUT";
private static final String SERVER_LANGUAGE_CODE =
FtpFileSystemConfigBuilder.class.getName() + ".SERVER_LANGUAGE_CODE";
@@ -159,6 +160,25 @@
}
/**
+ * @see #getDataTimeout
+ */
+ public Integer getSoTimeout()
+ {
+ return (Integer) getParam(SO_TIMEOUT);
+ }
+
+ /**
+ * set the socket timeout for the ftp client.<br />
+ * If you set the socketTimeout to <code>null</code> no socketTimeout will be set on the
+ * ftp client.
+ *
+ * @param soTimeout The timeout value
+ */
+ public void setSoTimeout(Integer soTimeout)
+ {
+ setParam(SO_TIMEOUT, soTimeout);
+ }
+ /**
* get the language code used by the server. see {@link org.apache.commons.net.ftp.FTPClientConfig}
* for details and examples.
* @return The language code of the server.
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/sftp/SftpFileObject.java Fri Nov 6 17:47:05 2009
@@ -301,7 +301,25 @@
return null;
}
- vector = channel.ls(".");
+ try
+ {
+ vector = channel.ls(".");
+ }
+ catch (SftpException e)
+ {
+ try
+ {
+ if (relPath != null)
+ {
+ channel.cd(workingDirectory);
+ }
+ }
+ catch (SftpException e2)
+ {
+ throw e;
+ }
+ throw e;
+ }
try
{
Modified: commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ commons/proper/vfs/branches/VFS281/core/src/main/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Fri Nov 6 17:47:05 2009
@@ -639,18 +639,24 @@
throw ex;
}
}
- if (fileExists)
+ if (!fileExists)
{
- if (!isCheckedIn)
+ createVersion(urlStr);
+ try
+ {
+ DavPropertySet props = getPropertyNames(fileName);
+ isCheckedIn = !props.contains(VersionControlledResource.CHECKED_OUT);
+ }
+ catch (FileNotFoundException fnfe)
{
- CheckinMethod checkin = new CheckinMethod(urlStr);
- setupMethod(checkin);
- execute(checkin);
+ // Ignore the error
}
}
- else
+ if (!isCheckedIn)
{
- createVersion(urlStr);
+ CheckinMethod checkin = new CheckinMethod(urlStr);
+ setupMethod(checkin);
+ execute(checkin);
}
}
else
Modified: commons/proper/vfs/branches/VFS281/pom.xml
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/pom.xml?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/pom.xml (original)
+++ commons/proper/vfs/branches/VFS281/pom.xml Fri Nov 6 17:47:05 2009
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>11</version>
+ <version>12</version>
<!-- The relative path is set to the current directory so the checkstyle plugin will work -->
<relativePath>.</relativePath>
</parent>
Modified: commons/proper/vfs/branches/VFS281/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/branches/VFS281/xdocs/changes.xml?rev=833493&r1=833492&r2=833493&view=diff==============================================================================
--- commons/proper/vfs/branches/VFS281/xdocs/changes.xml (original)
+++ commons/proper/vfs/branches/VFS281/xdocs/changes.xml Fri Nov 6 17:47:05 2009
@@ -23,6 +23,18 @@
<body>
<release version="2.0" date="in SVN" description="">
+ <action dev="rgoers" type="fix" issue="VFS-216" due-to="Reetu Mutti">
+ The FTP Configuration includes an option to set a timeout for the data connection, but not for the socket
+ timeout. This is a problem, as idle sockets can cause your download to hang forever and never timeout.
+ </action>
+ <action dev="rgoers" type="fix" issue="VFS-289" due-to="Kirill Safonov">
+ FTP connection is not released If exception is thrown out of FtpFileObject.doGetOutputStream().
+ </action>
+ <action dev="rgoers" type="fix" issue="VFS-286" due-to="Kirill Safonov">
+ SftpFileObject.doListChildrenResolved() changes the working dir before doing ChannelSftp.ls() call.
+ If ls() throws an exception, the current directory is not reset. All the subsequent operations that rely on the
+ current dir will fail trying to change into nonexistent directory.
+ </action>
<action dev="rgoers" type="add" issue="VFS-244">
Rename HttpRandomAccesContent to HttpRandomAccessContent.
</action>
Propchange: commons/proper/vfs/branches/VFS281/xdocs/testing.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 6 17:47:05 2009
@@ -0,0 +1,2 @@
+/commons/proper/vfs/trunk/xdocs/testing.xml:812326-832523
+/jakarta/commons/sandbox/vfs/trunk/xdocs/testing.xml:147755-178259