Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2541

When storing binaries in the FS binary store, avoid closing the hashing stream twice

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Minor Minor
    • 5.0.0.Final, 4.6.0.Final
    • 4.5.0.Final
    • Storage
    • None

      When storing binary files in the FS binary store, ModeShape calculates the SHA1 of the binary data. This is done via a hashing stream which atm. is closed twice after the SHA1 is computed.

      As per the contract of the close method:

      public interface Closeable extends AutoCloseable {
      
          /**
           * Closes this stream and releases any system resources associated
           * with it. If the stream is already closed then invoking this
           * method has no effect.
           *
           * <p> As noted in {@link AutoCloseable#close()}, cases where the
           * close may fail require careful attention. It is strongly advised
           * to relinquish the underlying resources and to internally
           * <em>mark</em> the {@code Closeable} as closed, prior to throwing
           * the {@code IOException}.
           *
           * @throws IOException if an I/O error occurs
           */
          public void close() throws IOException;
      

      this should not be a problem. It seems however that certain streams (see linked forum issue) do not implement this contract properly, causing potential exceptions.

              hchiorean Horia Chiorean (Inactive)
              hchiorean Horia Chiorean (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: