Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022587

ClassCache is not optimal and leaks Source instances

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • core-libs
    • None
    • b110
    • generic
    • generic

    Description

      By using a Source instance as a key, the cache requires that content be read into memory simply to make the comparison. URL comparison, when possible, can be done instead using content length and last modified time to avoid this overhead. For the very rare environments where comparing length and time is insufficient (e.g. misbehaved URL handler implementations or time stamp rounding with rapidly changing content), a configuration to perform full comparison or to simply disable the cache may be desirable.

      Additionally, the cache leaks Source instances since there is no logic to remove keys whose values have been collected.

      The attached ClassMap/ClassCache implementation addresses both issues, as an example (feel free to use if it makes sense). This implementation is also thread-safe since ultimately the cache should be on Context rather than Global so that it can be shared across threads :).

      Attachments

        Activity

          People

            hannesw Hannes Wallnoefer
            batsatt Bryan Atsatt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: