XWiki Platform
  1. XWiki Platform
  2. XWIKI-7749

ImagePlugin caches image thumnail bytes, but new temporary files for each are recreated on each request

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.5, 4.0
    • Fix Version/s: 4.4-rc-1
    • Component/s: Old Core
    • Labels:
    • Environment:
      Tomcat 7, Windows XP, Java 6
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Documentation:
      n/a
    • Documentation in Release Notes:
      n/a
    • Similar issues:

      Description

      The ImagePlugin re-creates thumbnail temporary files on every request, despite the fact that the original image and thumbnail image content may be cached.

      The ImagePlugin.downloadImageFromCache method caches the thumbnail after is is resized by the shrinkImage() method, but on subsequent requests the
      XWikiAttachment is cloned and the .setContent(InputStream,int) method set from the cached data which causes a new temporary file to be created every time.

      Right now it serves the bytes to the client by:

      • Getting the image bytes from the cache
      • writing those cached bytes out to disk from the cache by re-creating a new temporary file (unless the memory file size threshold was not reached - 10kb)
      • Re-reading those image bytes from the file via the DiskFileItem to serve to the servlet response.

      If a page has multiple images (eg. 20+ images) shown as thumbnails then the disk space consumed can start to grow fairly quickly.

      Could the cached bytes be used directly instead of re-creating a new temporary file?

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              CalebJamesDeLisle
              Reporter:
              Jamie Maher
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: