xadisk
  1. xadisk
  2. XADISK-121

moveFile fails with java.lang.AssertionError

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.2
    • Component/s: filesystem
    • Labels:
      None
    • Environment:

      Windows 7 64bit
      JDK 1.6.0_29

      Description

      I'm trying to rename an empty directory

      File emptyDir = new File(dataRoot, "empty");
      File newDir = new File(dataRoot, "dir3");
      session.moveFile(emptyDir, newDir);

      The dataRoot is a root of directory three, XADisk operates on. The empty directory already exists (and is empty) and dir3 does not exist.
      The moveFile operation fails with:

      java.lang.AssertionError
      at org.xadisk.filesystem.NativeLock.getHolders(NativeLock.java:54)
      at org.xadisk.filesystem.NativeConcurrencyControl.pinLockTreeNode(NativeConcurrencyControl.java:266)
      at org.xadisk.filesystem.NativeConcurrencyControl.pinDirectoryTree(NativeConcurrencyControl.java:241)
      at org.xadisk.filesystem.NativeConcurrencyControl.pinDirectoryForRename(NativeConcurrencyControl.java:236)
      at org.xadisk.filesystem.NativeSession.moveFile(NativeSession.java:304)

        Activity

        Hide
        Nitin Verma added a comment - - edited

        Hello.

        Thanks for identifying and reporting the issues.

        I wrote a simple test (inlined below) for the use-case you described, but it works fine for me; may be something is different in this test-case and the situation where you saw the reported issue:

        ____________________________________________________________________________________________________________

        StandaloneFileSystemConfiguration configuration = new StandaloneFileSystemConfiguration("C:/xadisk", "1");
        XAFileSystem xafs = XAFileSystemProxy.bootNativeXAFileSystem(configuration);
        xafs.waitForBootup(-1);
        System.out.println("Successfully booted xadisk.");

        Session session = xafs.createSessionForLocalTransaction();
        session.moveFile(new File("C:/empty"), new File("C:/dir3"));
        session.moveFile(new File(new File("C:/dataRoot"), "empty"), new File(new File("C:/dataRoot"), "dir3"));
        session.commit();
        ____________________________________________________________________________________________________________

        May be you can describe your test-case in more detail.

        Thanks,
        Nitin

        Show
        Nitin Verma added a comment - - edited Hello. Thanks for identifying and reporting the issues. I wrote a simple test (inlined below) for the use-case you described, but it works fine for me; may be something is different in this test-case and the situation where you saw the reported issue: ____________________________________________________________________________________________________________ StandaloneFileSystemConfiguration configuration = new StandaloneFileSystemConfiguration("C:/xadisk", "1"); XAFileSystem xafs = XAFileSystemProxy.bootNativeXAFileSystem(configuration); xafs.waitForBootup(-1); System.out.println("Successfully booted xadisk."); Session session = xafs.createSessionForLocalTransaction(); session.moveFile(new File("C:/empty"), new File("C:/dir3")); session.moveFile(new File(new File("C:/dataRoot"), "empty"), new File(new File("C:/dataRoot"), "dir3")); session.commit(); ____________________________________________________________________________________________________________ May be you can describe your test-case in more detail. Thanks, Nitin
        Hide
        titmus added a comment -

        Did you run your code with assertions enabled (-ea switch for java)?
        Without it it runs fine indeed. I noticed it in my unit tests which are by default run with assertions enabled by surefire Maven plugin. When assertions are disabled the test pass and does the move. But when assertions are enabled it fails.

        Show
        titmus added a comment - Did you run your code with assertions enabled (-ea switch for java)? Without it it runs fine indeed. I noticed it in my unit tests which are by default run with assertions enabled by surefire Maven plugin. When assertions are disabled the test pass and does the move. But when assertions are enabled it fails.
        Hide
        Nitin Verma added a comment -

        Thanks! Yes, I was actually running with assertions disabled. Now I could reproduce the issue. The fix was trivial. So, I am also checking-in the changes to trunk for you to see over svn (please ignore those other corrections related to indentation).

        Show
        Nitin Verma added a comment - Thanks! Yes, I was actually running with assertions disabled. Now I could reproduce the issue. The fix was trivial. So, I am also checking-in the changes to trunk for you to see over svn (please ignore those other corrections related to indentation).
        Hide
        Nitin Verma added a comment -
        Show
        Nitin Verma added a comment - Checked-in the changes to trunk ( http://java.net/projects/xadisk/sources/svn/revision/525 ).
        Hide
        titmus added a comment -

        I tried the version from the trunk and it works for me. Great job!

        Show
        titmus added a comment - I tried the version from the trunk and it works for me. Great job!

          People

          • Assignee:
            Nitin Verma
            Reporter:
            titmus
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: