Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1249

DataFileWriter doesn't correctly conform to Closeable

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.3
    • 1.7.4
    • java
    • None
    • Incompatible change
    • DataFileWriter#close() may now be called on a writer that has already been closed (i.e. conforms to Closeable).

    Description

      o.a.avro.file.DataFileWriter implements java.io.Closeable, but violates the contract stated by the interface's close() method javadoc.

      Closes this stream and releases any system resources associated
      with it. If the stream is already closed then invoking this
      method has no effect.

      DataFileWriter's close() calls flush() calls sync() which calls assertOpen(). This causes repeated calls to close(), or those on a file that failed to open, to throw an exception which violates the contract. Notably, the following idiom fails (and shouldn't).

      import com.google.common.io.Closeables;
      
      // ...
      
      DataFileWriter writer = null;
      
      try {
        writer = new DataFileWriter(...);
      
        // ...
      } finally {
        Closeables.closeQuietly(writer);
      }
      

      Attachments

        1. AVRO-1249.patch
          0.7 kB
          Eric Sammer
        2. AVRO-1249-2.patch
          1 kB
          Eric Sammer

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            esammer Eric Sammer
            esammer Eric Sammer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment