Menu

#34 Automatically open read only formats as read-only

2.1.6
closed
nobody
None
1
2016-11-12
2016-09-29
No

Documentation states a file will be opened in read-only if it is not writeable, but this is not the case if the JetFormat is read-only. The DatabaseImpl.open(...) method only checks for file permissions, resulting in an IOException at line 387.

Tested on version 2.1.4 (latest on maven).

Discussion

  • James Ahlborn

    James Ahlborn - 2016-09-30
     
  • James Ahlborn

    James Ahlborn - 2016-09-30

    I'm not sure i understand the bug? if the file is read only, it will automatically be opened read-only. otherwise, it will honor the read-only option parameter passed to the open method call.

    for database formats for which jackcess does not support writing, the caller should set the read-only flag. if you don't set this flag, then you are indicating to jackcess that you intend on writing to the file (which is why jackcess then throws an exception).

     
  • Dieter De Paepe

    Dieter De Paepe - 2016-09-30

    Then maybe I misunderstood the documentation. In my case, I did not know which version of Access files I would be working with. So I read the documentation stating that any non-writable files will be opened as read-only, that seems good. But when I run the code, I get an IOException stating that the file is read-only. That seemed like a mistake in the documentation to me.

    I admit it's a minor thing that is easily fixed when looking at the details of the open function, but that shouldn't be needed in my oppinion.

     
  • James Ahlborn

    James Ahlborn - 2016-10-01

    So, your expectation is that if you open a old format file, that it would automatically become read-only, and then you would subsequently get an exception if you attempted to write to the file?

     
    • Dieter De Paepe

      Dieter De Paepe - 2016-10-01

      Yes, that is how I would intrepret the current documentation.

      On 1 October 2016 at 02:45, James Ahlborn jahlborn@users.sf.net wrote:

      So, your expectation is that if you open a old format file, that it would
      automatically become read-only, and then you would subsequently get an
      exception if you attempted to write to the file?


      Status: open
      Group: Unassigned
      Created: Thu Sep 29, 2016 02:35 PM UTC by Dieter De Paepe
      Last Updated: Fri Sep 30, 2016 07:39 AM UTC
      Owner: nobody

      Documentation states a file will be opened in read-only if it is not
      writeable, but this is not the case if the JetFormat is read-only. The
      DatabaseImpl.open(...) method only checks for file permissions, resulting
      in an IOException at line 387.

      Tested on version 2.1.4 (latest on maven).

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/jackcess/bugs/137/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • James Ahlborn

    James Ahlborn - 2016-11-12

    Ticket moved from /p/jackcess/bugs/137/

     
  • James Ahlborn

    James Ahlborn - 2016-11-12
    • summary: Documentation error in Database.open(File) --> Automatically open read only formats as read-only
    • Group: Unassigned --> Unnassigned
     
  • James Ahlborn

    James Ahlborn - 2016-11-12

    I tweaked the title and turned this into a feature request. since people seem to continue to stumble over this, i've changed the behavior so it automatically switches to read-only mode in this situation.

    fixed in trunk, will be in the 2.1.6 release.

     
  • James Ahlborn

    James Ahlborn - 2016-11-12
    • status: open --> closed
    • Group: Unnassigned --> 2.1.6
     

Log in to post a comment.

MongoDB Logo MongoDB