This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 196820 - Remote file chooser can not work with directories that contain spaces.
Summary: Remote file chooser can not work with directories that contain spaces.
Status: RESOLVED WORKSFORME
Alias: None
Product: cnd
Classification: Unclassified
Component: Remote (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal with 2 votes (vote)
Assignee: Vladimir Kvashin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-17 19:36 UTC by epele83
Modified: 2011-04-14 16:31 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 177670


Attachments
stacktrace (4.15 KB, text/plain)
2011-03-17 19:36 UTC, epele83
Details
Remote File View (linux client, windows + cygwin server) (28.38 KB, image/png)
2011-03-24 10:50 UTC, epele83
Details

Note You need to log in before you can comment on or make changes to this bug.
Description epele83 2011-03-17 19:36:28 UTC
Build: NetBeans IDE 6.9.1 (Build 201011082200)
VM: Java HotSpot(TM) 64-Bit Server VM, 19.1-b02, Java(TM) SE Runtime Environment, 1.6.0_24-b07
OS: Linux

User Comments:
epele83: Using a remote windows machine
* It has cygwin installed to connect by ssh (connection works)
* try to use the browse button to open a JFileChooser as for a remote linux machine
NPE occours (I suppose some problems related to the hostInfo.getUserDir() and hostInfo.getUserDirFile() methods)
Forgot to say, I'm using a linux client and try to connect to a windows machine.
Thanks in advance
-Paolo




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.remote.api.ui.FileObjectBasedFile.<init>(FileObjectBasedFile.java:83)
   at org.netbeans.modules.remote.api.ui.RemoteFileSystemView.getHomeDirectory(RemoteFileSystemView.java:136)
   at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFileChooserUI.java:253)
   at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:136)
   at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserUI.java:126)
   at javax.swing.JComponent.setUI(JComponent.java:662)
Comment 1 epele83 2011-03-17 19:36:32 UTC
Created attachment 107089 [details]
stacktrace
Comment 2 epele83 2011-03-17 20:22:35 UTC
My apologies, I increase priority to P2 because it's blocking for the use of remote api in our RCP application.
Thanks in advance
-Paolo
Comment 3 epele83 2011-03-24 10:50:05 UTC
Created attachment 107239 [details]
Remote File View (linux client, windows + cygwin server)
Comment 4 epele83 2011-03-24 10:51:28 UTC
I found an easy patch for the NPE.
as for the constructor

at line 80 of org.netbeans.modules.remote.api.ui.FileObjectBasedFile

    public FileObjectBasedFile(ExecutionEnvironment env, FileObject fo) {
        super( fo == null || "".equals(fo.getPath()) ? "/" : fo.getPath());
        this.fo = fo;
        this.path = fo == null || "".equals(fo.getPath()) ? "/" : fo.getPath(); //add NPE protection as for super(...) call
        this.env = env;
    }

Now we can open the Remote File Chooser but we have some problems with the folder that contains some space.
It happen that this folders are split in different files.
Es: Documents and Settings -> 3 different files: "Documents" "and" "Settings"

Second, the parent folder should be /cygdrive/c/ and not just /cygdrive/

Thanks in advanced.
-Paolo
Comment 5 Vladimir Kvashin 2011-04-14 15:39:17 UTC
Hi,
Several issues are mixed here.

First one is NPE. It is a duplicate of issue 189307 that has been already fixed (and the fix was exactly the same you propose - see http://hg.netbeans.org/cnd-main/rev/9b71548ab1ea).

The second one is inability of remote file chooser to work with directories that contain a space. So let's consider this issue is exactly against this.

The third one is working from Linux to Windows. The remote wasn't intended to work this way; you can file an enhancement if you wish; however it's unlikely that we'll invest in this. Which doesn't mean it necessarily won't work - it probably will (in sharing mode).
Comment 6 epele83 2011-04-14 15:54:17 UTC
I'm creating a fix for that.
In org.netbeans.modules.cnd.remote.fs.RemoteFileSupport

line 222:

        final String rdir = remoteDir.length() == 0 ? "/" : remoteDir; // NOI18N
        checkConnection(dir, rdir, true);

        //my hack for cygdrive replace (otherwise we have some other problem)
        //not best check... but only for testing

        String _rdir = rdir.replaceAll("cygdrive", "cygdrive/c");

        final String script = "test -d \"" + _rdir + "\" && " + // NOI18N
                "cd \"" + _rdir + "\" && " + // NOI18N
                "for D in "+ _rdir + "/*; do if [ -d \"$D\" ]; then echo D \"`basename \"$D\"`\"; else echo F \"`basename \"$D\"`\"; fi; done";
        System.out.println(_rdir + ":----\n" + script);

        final AtomicReference<IOException> ex = new AtomicReference<IOException>();
        final AtomicBoolean dirCreated = new AtomicBoolean(false);

instead to use /bin/ls try to seach for <dir>/* then the space are handle in the right way.

Thanks Paolo
Comment 7 Vladimir Kvashin 2011-04-14 16:08:58 UTC
Thank you for your effort!
But you do this against old, 6.9.x code base.
Now we do this via sftp and don't parse ls; RemoteFileSupport is quite different as well. However the issue still exists (which is sure a shame upon me). I believe I'll fix it today and it will be available in development version quite soon.
Comment 8 epele83 2011-04-14 16:12:10 UTC
Thanks a lot, Do you know if this fix can be ported in NB 7.0.
Thanks again
-Paolo
Comment 9 Vladimir Kvashin 2011-04-14 16:31:15 UTC
I was mistaken. 
The issue with spaces is fixed in 7.0 and development version.