Bug 45735 - Updated ResourceAttributes.getETag
Updated ResourceAttributes.getETag
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
6.0.18
PC Linux
: P2 minor (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2008-09-03 10:48 UTC by Remy Maucherat
Modified: 2008-10-27 06:27 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Maucherat 2008-09-03 10:48:23 UTC
After looking at a user's list post, I noticed the implementation was not consistent with the other getters (like getName).

I propose changing it to:
    public String getETag(boolean strong) {
        if (strong) {
            // The strong ETag must always be calculated by the resources
            if (strongETag != null)
                return strongETag;
            if (attributes != null) {
                Attribute attribute = attributes.get(ETAG);
                if (attribute != null) {
                    try {
                        strongETag = attribute.get().toString();
                    } catch (NamingException e) {
                        ; // No value for the attribute
                    }
                }
            }
            return strongETag;
        } else {
            // The weakETag is contentLenght + lastModified
            if (weakETag == null) {
                weakETag = "W/\"" + getContentLength() + "-" 
                    + getLastModified() + "\"";
            }
            return weakETag;
        }
    }
Comment 1 Chris Hubick 2008-09-27 15:54:00 UTC
I just saw this, after having filed bug 45906 with more extensive fixes.
Comment 2 Mark Thomas 2008-10-27 06:27:40 UTC
This has been applied to 6.0.x and will be in 6.0.19 onwards.