jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13873] New: - CacheEntry does not compute the proper size in bytes
Date Wed, 23 Oct 2002 08:52:36 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13873>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13873

CacheEntry does not compute the proper size in bytes

           Summary: CacheEntry does not compute the proper size in bytes
           Product: Taglibs
           Version: 1.0
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Cache  Taglib
        AssignedTo: taglibs-dev@jakarta.apache.org
        ReportedBy: chevalier@mkms.xerox.com


LRUCache.CacheEntry uses String.length() to compute the size of a string in 
bytes. The specification states that String.length() return the number of 16-
bit Unicode characters in the string. Unicode characters are usually 
represented using two bytes. Hence the real size is actually twice as big as 
the store one.

Another minor issue is that size was only registered when lifetime was superior 
to zero.

Below is a modified version of the constructor:
   public CacheEntry(String value) {
      this.value = value;
      if (lifetime > 0) {
        this.expiration = (new Date()).getTime() + lifetime;
      }

      // Pitch's fix: String.length() return the number of 16-bit Unicode 
      // characters in the string. Unicode characters are usually represented 
      // using two bytes. For Chinese characters or new Unicode schema, we
      // would be closer to reality by calling: String.getBytes().length
      this.size = 2 * value.length();
    }

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message