Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-7749

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.4-rc-1
    • 3.5, 4.0
    • Old Core
    • Tomcat 7, Windows XP, Java 6
    • Unit
    • Unknown
    • n/a
    • n/a

    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?

      Attachments

        Issue Links

          Activity

            People

              calebjamesdelisle CalebJamesDeLisle
              jamiem Jamie Maher
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: