• Bug
  • Status: Closed
  • 1 Critical
  • Resolution: Fixed
  • ehcache-core
  • nbangarw
  • Reporter: ryebrye
  • November 15, 2011
  • 0
  • Watchers: 2
  • July 27, 2012
  • December 01, 2011

Description

import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class EhcacheReplacementRegressionTest {

    @Test
    public void testReplaceMethod2() throws Exception {
        net.sf.ehcache.CacheManager manager = new CacheManager();
        net.sf.ehcache.config.CacheConfiguration cacheConfiguration = new net.sf.ehcache.config.CacheConfiguration();
        cacheConfiguration.setName("testCache");
        cacheConfiguration.setCopyOnRead(true);
        cacheConfiguration.setCopyOnWrite(true);
        net.sf.ehcache.Ehcache cache = new net.sf.ehcache.Cache(cacheConfiguration);
        manager.addCache(cache);

        Long key = System.currentTimeMillis();
        String value = "value" + key;
        cache.put(new Element(new Long(key), new String(value)));
        String nextValue = "value" + key + 1;
        assertThat(cache.replace(new Element(new Long(key), new String(value)), new Element(new Long(key), new String(nextValue))), is(true));
        Assert.assertEquals(nextValue, cache.get(key).getValue());
    }

}

The above test passes in 2.4.6 but fails in 2.5.0

(In 2.5.0 that replace method returns false)

Comments

Fiona OShea 2011-11-30

Trunk and 2.5.x

Nishant Bangarwa 2011-12-01

Fixed and added a test to verify it.