#48 Make the bufferio operations exception-safe


jEdit has serious bugs in bufferio. If an exception is
thrown during the final stream write/read oepration,
following problems occur:
The contents of the original file are lost. For
this case, jEdit provides "two-stage save" option.
But if the backup options are also enabled, the
file is moved to backup. Then the original file
seems to disappear. Also the stream is left open.
The stream is left open.
This patch will fix these problems.


  • Kazutoshi Satoda

    Logged In: YES
    Originator: YES

    Here are some additional information about this patch.
    Comments are welcome.

    I noticed this while working to fix some looseness
    about encodings. I need this to be fixed before
    throwing decoding/encoding error from read/write
    operations. But the problem is probably more general
    one. So I made a separated patch first.

    I also noticed that the auto-save operation does not
    see settings such as "two-stage save". Is this
    intended? I personally don't care because I don't use
    the auto-save option. But if I implement strict
    checking about encoding, a dangerous scenario will
    come to mind.
    - Enable auto-save option.
    - Set buffer encoding to US-ASCII.
    - Type some non-ASCII char (this might be an accident)
    Then, auto-saving will be fired and the contents
    of the file will be lost. Should I also implement
    two-stage saving and backuping into the auto-save
    option before throwing decoding/encoding errors?

  • Alan Ezust

    Alan Ezust - 2006-11-25
    • assigned_to: nobody --> ezust
    • status: open --> closed-accepted

Log in to post a comment.