History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-183
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andres March
Reporter: cott
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OSCache

HashDiskPersistenceListener / MessageDigest not thread safe

Created: 30/Jun/05 12:39 AM   Updated: 04/Mar/06 01:49 AM
Component/s: Listeners
Affects Version/s: 2.1.1
Fix Version/s: 2.3


 Description  « Hide
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at sun.security.provider.DigestBase.engineUpdate(DigestBase.java:102)
        at sun.security.provider.MD5.implDigest(MD5.java:95)
        at sun.security.provider.DigestBase.engineDigest(DigestBase.java:161)
        at sun.security.provider.DigestBase.engineDigest(DigestBase.java:140)
        at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:531)
        at java.security.MessageDigest.digest(MessageDigest.java:309)
        at java.security.MessageDigest.digest(MessageDigest.java:355)
        at com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener.getCacheFileName(HashDiskPersistenceListener.java:65)
        at com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener.getCacheFile(AbstractDiskPersistenceListener.java:375)
        at com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener.retrieve(AbstractDiskPersistenceListener.java:207)
        at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.persistRetrieve(AbstractConcurrentReadCache.java:1056)
        at com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.get(AbstractConcurrentReadCache.java:725)
        at com.opensymphony.oscache.base.Cache.getCacheEntry(Cache.java:612)
        at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:230)
        at com.opensymphony.oscache.web.tag.CacheTag.doStartTag(CacheTag.java:486)


 All   Comments   Change History      Sort Order:
anjan bacchu - [24/Feb/06 02:52 AM ]
hi there,

this problem is because of overwriting by multiple threads.

see a similar post on sun's site -- http://forum.java.sun.com/thread.jspa?threadID=700440&tstart=90

MessageDigest instance md is not thread safe -- guard it and then this exception will NOT happen.

BR,
~A

/**
     * Generates a file name for the given cache key. In this case the file name is attempted to be
     * generated from the hash of the standard key name. Cache algorithm is configured via the
     * <em>cache.persistence.disk.hash.algorithm</em> configuration variable.
     * @param key cache entry key
     * @return char[] file name
     */
    protected char[] getCacheFileName(String key) {
        byte[] digest;

if ((key == null) || (key.length() == 0)) {
            throw new IllegalArgumentException("Invalid key '" + key + "' specified to getCacheFile.");
        }

digest = md.digest(key.getBytes());


Lars Torunski - [01/Mar/06 01:09 AM ]
MessageDigest not thread safe, synchronized added.
Fixed in CVS HEAD.