[ 
https://issues.apache.org/jira/browse/OLINGO-239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13965310#comment-13965310
 ] 

Gerben Kegel commented on OLINGO-239:
-------------------------------------

What is, at your machine, the output of the following program?

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

public class Test {
    
    public static void main(String... args) {
        new Test().run();
    }
    
    private void run() {
        File f = new File("space space");
        f.mkdirs();
        
        ClassLoader cl = this.getClass().getClassLoader();
        URL url = cl.getResource("space space");
        File file  = new File(url.getFile());
        System.out.println(file.isDirectory());
        
        System.out.println(url.getFile());
        File file2  = new File(url.getFile().replace("%20", " "));
        System.out.println(file2.isDirectory());
    }
}
}}

For our machines, it always is first false, then true, indicating that there's 
a problem when you have spaces in your path.

> ClassHelper doesn't find classes when there's a space in the path
> -----------------------------------------------------------------
>
>                 Key: OLINGO-239
>                 URL: https://issues.apache.org/jira/browse/OLINGO-239
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-annotation
>    Affects Versions: V2 1.2.0
>            Reporter: Gerben Kegel
>            Assignee: Michael Bolz
>            Priority: Trivial
>
> When you have space in your path and ask the ClassHelper to loadClasses(...), 
> it doesn't find anything. The problem is because an URL class is used where 
> the space converted to a %20. This URL does not point to a file anymore.
> Please call the following function (using .toUri().getPath()) to fill 
> fqnForClasses in line 71.
> {{
> private static Collection<String> getFqnForClasses(String packageToScan, URL 
> url, FilenameFilter ff) {
>         try {
>             File folder = new File(url.toURI().getPath());
>             if (folder.isDirectory()) {
>                 return getClassFqnFromDir(ff, folder, packageToScan);
>             } else if (isJarFile(url)) {
>                 return getClassFqnFromJar(url.getFile().substring(5), 
> packageToScan);
>             }
>         } catch (URISyntaxException ex) {
>         }
>         return null;
>     }
> }}
> Thank you



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to