Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8F8BC17698 for ; Mon, 16 Mar 2015 11:08:06 +0000 (UTC) Received: (qmail 21787 invoked by uid 500); 16 Mar 2015 11:08:05 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 21650 invoked by uid 500); 16 Mar 2015 11:08:05 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 21639 invoked by uid 99); 16 Mar 2015 11:08:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Mar 2015 11:08:05 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of geoff.watters@oracle.com designates 156.151.31.81 as permitted sender) Received: from [156.151.31.81] (HELO userp1040.oracle.com) (156.151.31.81) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Mar 2015 11:07:57 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t2GB7aEc027498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Mar 2015 11:07:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t2GB7ZVo011069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 16 Mar 2015 11:07:36 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t2GB7Zc5001420 for ; Mon, 16 Mar 2015 11:07:35 GMT Received: from [10.175.204.221] (/10.175.204.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Mar 2015 04:07:35 -0700 Message-ID: <5506B975.1050506@oracle.com> Date: Mon, 16 Mar 2015 11:07:33 +0000 From: Geoff Watters Organization: Oracle Corporation User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: user@commons.apache.org Subject: [vfs] vsf2.2.0: non-ascii chars in file name are not handled by createFolder() Content-Type: multipart/alternative; boundary="------------080406050204080005080709" X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-Virus-Checked: Checked by ClamAV on apache.org --------------080406050204080005080709 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit All I am using*commons-vfs2-2.0.jar* and am running into problems when file names contain non-ascii characters. According to https://issues.apache.org/jira/browse/VFS-305 this has been fixed/shipped in 2.0. In my environment I am able to create such file names when using ftp on the command-line (Red Hat Enterprise Linux Server release 5.8 (Tikanga)). When I execute the following sample code, I get the output shown below. public class FtpTest { public static void main(String[] args) throws FileSystemException { String host="hhh"; String user = "uuu"; String password = "ppp"; String destDir = "/tmp"; FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setControlEncoding(opts, "UTF-8"); DefaultFileSystemManager manager = new DefaultFileSystemManager(); manager.addProvider("ftp", new FtpFileProvider()); manager.init(); String root="ftp://"+user+":"+password+"@"+host+destDir; // Specify a number of directories that should be created under destDir String[] lRoots = new String[4]; lRoots[0]= root+"/ftpDebug"; lRoots[1]= root+"/ftp\u7684Debug"; // insert a non-ascii char lRoots[2]= root+"/ftp\u7685Debug"; // insert a different non-ascii char lRoots[3]= root+"/ftp\u7684Debug"; // insert the same non-ascii char // Verify the ControlEncoding System.out.println("ControlEncoding is "+FtpFileSystemConfigBuilder.getInstance().getControlEncoding(opts)); int dirCount=0; for (String lRoot: lRoots) { System.out.println(dirCount+") Process directory ["+lRoot+"]"); FileObject newDir = manager.resolveFile(lRoot, opts); if (!newDir.exists()) { try { System.out.println(dirCount+") "+lRoot+" ::Dir Does Not Exist so Create It "); newDir.createFolder(); if (newDir.exists()) System.out.println(dirCount+") "+lRoot+" ::Creation Successful "); else System.out.println(dirCount+") "+lRoot+" ::Creation Fails "); } catch (Exception ex) { System.out.println(dirCount+") "+lRoot + " raised "+ex); } } else System.out.println(dirCount+") "+lRoot+" ::Dir Already Exists "); dirCount++; } } } The output from running the above is:- ControlEncoding is UTF-8 0) Process directory [ftp://uuu:ppp@hhh/tmp/ftpDebug] 0) ftp://uuu:ppp@hhh/tmp/ftpDebug ::Dir Does Not Exist so Create It 0) ftp://uuu:ppp@hhh/tmp/ftpDebug ::Creation Successful 1) Process directory [ftp://uuu:ppp@hhh/tmp/ftpªDebug] 1) ftp://uuu:ppp@hhh/tmp/ftpªDebug ::Dir Does Not Exist so Create It 1) ftp://uuu:ppp@hhh/tmp/ftpªDebug ::Creation Successful 2) Process directory [ftp://uuu:ppp@hhh/tmp/ftp%Gçš…%@Debug] 2) ftp://uuu:ppp@hhh/tmp/ftp%Gçš…%@Debug ::Dir Does Not Exist so Create It 2) ftp://uuu:ppp@hhh/tmp/ftp%Gçš…%@Debug raised org.apache.commons.vfs2.FileSystemException: Could not create folder "ftp://uuu:***@hhh/tmp/ftp%Gçš…%@Debug". 3) Process directory [ftp://uuu:ppp@hhh/tmp/ftpªDebug] 3) ftp://uuu:ppp@hhh/tmp/ftpªDebug ::Dir Does Not Exist so Create It 3) ftp://uuu:ppp@hhh/tmp/ftpªDebug raised org.apache.commons.vfs2.FileSystemException: Could not create folder "ftp://uuu:***@hhh/tmp/ftpªDebug". After step 1) I see a directory called*/tmp/ftp?Debug*. I think this is causing the subsequent creation problem in step 2) and step 3). When a directory such as "*ftp\u7684Debug*" does exist, then *exists*() returns the correct result of true, but *createFolder*() creates a directory with name "*ftp?Debug*". Thanks in advance Geoff --------------080406050204080005080709--