Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-10581

Sitemap.close() violates contract of Closeable.close()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Sitemap 1.0.2
    • Sitemap 1.0.4
    • Extensions

    Description

      According to the contract of Closable.close()

      If the stream is already closed then invoking this method has no effect.

      (https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html#close--)

      But in https://github.com/apache/sling-org-apache-sling-sitemap/blob/e73387d510a1ac3ac762baa97338ab6c4e919bdc/src/main/java/org/apache/sling/sitemap/impl/builder/SitemapImpl.java#L79 an ISE is thrown if it has been closed before.

      Either implement AutoCloseable (https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) which states

      Note that unlike the close method of Closeable, this close method is not required to be idempotent. In other words, calling this close method more than once may have some visible side effect, unlike Closeable.close which is required to have no effect if called more than once. However, implementers of this interface are strongly encouraged to make their close methods idempotent.

      or allow close() being called twice without an exception.

      Attachments

        Activity

          People

            diru Dirk Rudolph
            kwin Konrad Windszus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: