xadisk
  1. xadisk
  2. XADISK-119

Wrong exception thrown by XADiskBasicIOOperations.getFileLength for missing file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 1.2.1
    • Fix Version/s: current
    • Component/s: filesystem
    • Labels:
      None
    • Environment:

      Windows 7 64bit
      JDK 1.6.0_29

      Description

      Invoking method XADiskBasicIOOperations.getFileLength on non-existing file throws InsufficientPermissionOnFileException instead of FileNotExistsException exception.

      Caused by: org.xadisk.filesystem.exceptions.InsufficientPermissionOnFileException: Permission of type [READ_FILE] is needed over the file/directory with path [C:\Users\titmus\AppData\Local\Temp\junit1370631598005369210\data\missing] for the i/o operation to succeed.
      at org.xadisk.filesystem.NativeSession.checkPermission(NativeSession.java:1078)
      at org.xadisk.filesystem.NativeSession.getFileLength(NativeSession.java:508)
      at org.xadisk.filesystem.NativeSession.getFileLength(NativeSession.java:495)

        Activity

        Hide
        Nitin Verma added a comment -

        All operations in XADiskBasicIOOperations are preceded by a permission check over the file/parent-file(directory). The fileLength operation is preceded by a read permission check over the input file. We call (in VirtualViewDirectory) Java File's canRead/canWrite methods without first checking for existence (this saves us an extra call to Java File's exists method), and these methods from Java File do not report any existence related exception - they simply say canRead/canWrite or not. This is the reason we cannot distinguish permission or existence issue.

        Leaving it as-designed for now, assuming a small compromise would be possible with the api users for the exception handling part. But anyone please feel free to comment back.

        Show
        Nitin Verma added a comment - All operations in XADiskBasicIOOperations are preceded by a permission check over the file/parent-file(directory). The fileLength operation is preceded by a read permission check over the input file. We call (in VirtualViewDirectory) Java File's canRead/canWrite methods without first checking for existence (this saves us an extra call to Java File's exists method), and these methods from Java File do not report any existence related exception - they simply say canRead/canWrite or not. This is the reason we cannot distinguish permission or existence issue. Leaving it as-designed for now, assuming a small compromise would be possible with the api users for the exception handling part. But anyone please feel free to comment back.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: