[jcifs] Re: jcifs code: ArrayIndexOutOfBoundsException in
SmbFile.java
Michael B Allen
mba2000 at ioplex.com
Wed Aug 27 06:12:45 EST 2003
Please send all correspondance to the jCIFS mailing list.
> Mike,
>
> I'm working on SMB browsing using Jcifs and have encountered a problem
> at lines 502ff of SmbFile (jcifs-0.7.11):
>
> int last = name.length() - 1;
> if ( name.charAt( last ) == '/' ) {
> name = name.substring( 0, last );
> }
>
> If I send in a url containing only "smb://" last becomes -1 and the
> substring() yields a ArrayIndexOutOfBoundsException. But if I test last
> for non-negativity I avoid the exception:
>
> int last = name.length() - 1;
> if ( last >= 0 &&
> name.charAt( last ) == '/' ) {
> name = name.substring( 0, last );
> }
>
> This seems like something others would have encountered, so it's likely
> I'm missing something.
The SmbFile constructor in question is not public. It is only used
internally by the listFiles method so 'name' should never be 'smb://'.
What is the input URL and with what constructor are you using it with? Do
you have a minimalistic sample of code that illustrates the problem?
>
> Thank you very much for the week you are doing on Jcifs.
It took us longer than a week! :)
Mike
More information about the jcifs
mailing list