Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1716

ConcurrentInitializer implementations can be instantiated and configured with allocation and release lambdas.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.x
    • 3.14.0
    • lang.concurrent.*
    • None

    Description

      Hello everyone.

      Currently there is no clean way to dispose of an object created with a LazyInitializer. Either you callĀ initializer.get().dispose(); but if you've never used initializer before this will invoke a potentially expensive routine just so the object can be immediately disposed.

      Or you cache the result of initializer.get(); and then dispose the object you have cached. This means the developer has to worry about concurrency issues when disposing the object, and looses all the benefits of LazyInitializer having a built in cache.

      To fix this I propose that a new variant of LazyInitializer is created, this variant will allow you to call a dispose method which will close the LazyInitializer object and then it will, if the wrapped object has been initialized, run whatever disposal routine is provided.

      I have created a pull request with a potential implementation here: https://github.com/apache/commons-lang/pull/1119

      Attachments

        Activity

          People

            Unassigned Unassigned
            benjaminconfino Benjamin Confino
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: