commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Defoort <filip...@cirquedigital.com>
Subject [VFS] NPE in rename()
Date Fri, 21 Jul 2006 13:39:45 GMT
Hi VFS,

I might just be getting tired now, but the following test fails
with a NPE:

import java.io.*;
import org.apache.commons.vfs.*;
import org.apache.commons.vfs.impl.*;

public class RenameCase {


   public static final void main(final String[] args) throws Exception {

            StandardFileSystemManager fileSystemManager
                 = new StandardFileSystemManager();

            fileSystemManager.setCacheStrategy(CacheStrategy.ON_RESOLVE);
            fileSystemManager.init();

            FileSystemOptions fileoptions = new FileSystemOptions();
            FileObject root = fileSystemManager.resolveFile("/tmp/", 
fileoptions);

            File dummy = new File("/tmp/test.txt");
            dummy.createNewFile();

            Writer w = new FileWriter(dummy);
            w.write("Some text");
            w.close();

            long size = dummy.length();

            FileObject fo = root.resolveFile("test.txt");
            FileObject fo2 = root.resolveFile("test2.txt");

            System.out.println("fo = " + fo);
            System.out.println("fo2 = " + fo2);

            fo.moveTo(fo2);

   }

fo = file:///tmp/test.txt
fo2 = file:///tmp/test2.txt
Exception in thread "main" java.lang.NullPointerException
        at 
org.apache.commons.vfs.provider.local.LocalFile.doRename(LocalFile.java:132)
        at 
org.apache.commons.vfs.provider.AbstractFileObject.moveTo(AbstractFileObject.java:930)
        at RenameCase.main(RenameCase.java:34)


Can anybody spot what I'm missing ?

Thanks,
- Filip



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message