Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1415

Cached entry is not flushed when a response contains a content-location header without an ETag header field

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.3.1
    • Fix Version/s: 4.3.2
    • Component/s: HttpCache
    • Labels:
      None
    • Environment:
      Windows 7, Tomcat

      Description

      When a response returns a content-location header, flushLocationCacheEntry is invoked on the content-location's URL. flushLocationCacheEntry causes the cached entry to be flushed if the entry is older than the response and the etags differ.

      However, the response and entry ETags are not considered different if either ETag header values are null(see:CacheInvalidator.responseAndEntryEtagsDiffer). This causes the resource referenced by the response's content-location header to remain cached.

      I'm not familiar with the HTTP spec, but the responseAndEntryEtagsDiffer, ETag null checks seem iffy.

      The same problem effects 4.2.5 as well.

      **Relevant code

      ***From CacheInvalidator.flushInvalidatedCacheEntries:
      final URL contentLocation = getContentLocationURL(reqURL, response);
      if (contentLocation != null) {
      flushLocationCacheEntry(reqURL, response, contentLocation);
      }

      ***From CacheInvalidator.flushLocationCacheEntry
      if (responseDateOlderThanEntryDate(response, entry)) {
      return;
      }
      if (!responseAndEntryEtagsDiffer(response, entry)) {
      return;
      }

      ***From CacheInvalidator.responseAndEntryEtagsDiffer:
      if (entryEtag == null || responseEtag == null) {
      return false;
      }

        Attachments

        1. CacheInvalidator.java.patch
          1 kB
          kyle leonhard

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kyle_leonhard kyle leonhard
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: