#698 Plugin loading fails when installdir has spaces

snapshot
closed-fixed
Rob Manning
Core (461)
9
2009-01-31
2009-01-01
Rob Manning
No

Tried to install SQuirreL snapshot (3.0) into C:\Program Files\SQuirreL SQL Client (the default) with Java 6 update 11 on WinXP Pro. Install succeeds, but when SQuirreL is launched, no plugins get loaded, as demonstrated by an empty plugin summary table. What follows is a note to Matt Dahlman (who first noticed the issue), CC'd to users list:

== BEGIN EMAIL ==

This looks like a bug in our code to me. It's odd that it hasn't turned up before now (Perhaps Sun fixed a bug in Java 6 that this bug was relying on). It has to do with how we transform File objects into URIs, then back into File objects again. In case you are looking for it in the code, MyURLClassLoader at line 111 returns false for both exists() and canRead() for C:/Program%20Files/SQuirreL%20SQL%20Client/plugins/codecompletion.jar when I hit that breakpoint with the debugger.

I wrote a small test that demonstrates in the fewest lines of code what we do with plugin jar files. The test driver takes a single argument which should be an absolute path to a file (don't forget quotes around paths with spaces). If you give it a path to a file without spaces, it reports that the file exists and a file built from it's URI also exists. However, if you give it a path to a file where spaces are in the path (for example, C:\Program Files), the file is reported to exist, but a file built from it's URI does not. You may notice that it encodes %20 for spaces to make a valid URI. My guess is the File API doesn't know how to deal with that.

I would attach the test driver, except that the last time I tried the mailing list rejected it - so it follows:

Rob

import java.io.File;
import java.net.URL;

public class FileUriTest
{

public static void main\(String args\[\]\) throws Exception \{
    File f = new File\(args\[0\]\);
    if \(f.exists\(\)\) \{
        System.out.println\("File \("+args\[0\]+"\) exists"\);
    \} else \{
        System.out.println\("File \("+args\[0\]+"\) does not exist"\);
    \}
    URL url = f.toURI\(\).toURL\(\);
    File f2 = new File\(url.getFile\(\)\);

    if \(f2.exists\(\)\) \{
        System.out.println\("File from URI \("+url.getFile\(\)+"\) exists"\);
    \} else \{
        System.out.println\("File from URI \("+url.getFile\(\)+"\) does not exist"\);
    \}
\}

}

== END EMAIL ==

This is marked high priority because it is likely that many users picking defaults for installations will experience this same problem.

Discussion

  • Rob Manning
    Rob Manning
    2009-01-01

    Fixed in CVS. Snapshot will be available soon.

    Rob

     
  • Rob Manning
    Rob Manning
    2009-01-01

    • status: open --> pending-fixed
     
  • Rob Manning
    Rob Manning
    2009-01-05

    • status: pending-fixed --> open-fixed
     
  • Rob Manning
    Rob Manning
    2009-01-31

    Matt Dahlman confirmed that this is no longer a problem with the latest snapshot.

    Rob

     
  • Rob Manning
    Rob Manning
    2009-01-31

    • status: open-fixed --> closed-fixed