You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by Vitali Baumtrok <vi...@stud.fh-kl.de> on 2012/02/22 14:35:30 UTC
Issue with file loading under Windows (LDAP API 1.0.0-M10)
The method
org.apache.directory.shared.ldap.sp.JavaStoredProcUtils.getClassFileAsStream(clazz:
Class<?>): byte[]
returns zero bytes under Windows if the path to the class contains at
least one space character. Because of that the
org.apache.directory.shared.ldap.sp.JavaStoredProcUtils.loadStoredProcedureClass(ctx:
LdapContext, clazz: Class<?>) doesn't work properly.
For example:
Reading the file "C:\a a\foo.class" would return zero bytes, because
clazz.getResource( classFileName ).getFile()
returns the String "/C:/a%20a/foo.class". So in the following
URL url = clazz.getResource( classFileName );
File file = new File( url.getFile() );
the file can not be found, because it searches for the "C:/a%20a"
directory which doesn't exist.
Solution:
Instead of url.getFile() use url.toURI()
Tip
Instead of clazz.getResourceAsStream( classFileName ) you can use
url.openStream(), it throws IOException.
Re: Issue with file loading under Windows (LDAP API 1.0.0-M10)
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 2/22/12 2:35 PM, Vitali Baumtrok a écrit :
> The method
> org.apache.directory.shared.ldap.sp.JavaStoredProcUtils.getClassFileAsStream(clazz:
> Class<?>): byte[]
> returns zero bytes under Windows if the path to the class contains at
> least one space character. Because of that the
> org.apache.directory.shared.ldap.sp.JavaStoredProcUtils.loadStoredProcedureClass(ctx:
> LdapContext, clazz: Class<?>) doesn't work properly.
>
> For example:
> Reading the file "C:\a a\foo.class" would return zero bytes, because
> clazz.getResource( classFileName ).getFile()
> returns the String "/C:/a%20a/foo.class". So in the following
> URL url = clazz.getResource( classFileName );
> File file = new File( url.getFile() );
> the file can not be found, because it searches for the "C:/a%20a"
> directory which doesn't exist.
>
> Solution:
> Instead of url.getFile() use url.toURI()
Good catch !!
Can you fill a JIRA ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com