• Bug
  • Status: Open
  • 2 Major
  • Resolution:
  • ehcache-server
  • Reporter: basmayor
  • August 20, 2010
  • 0
  • Watchers: 0
  • October 11, 2011

Description

Hi,

I noticed a few issues in creating and deleting a transient cache in the ehcache server:

When creating a cache using the method ‘createCache’ below, It takes three invocations to get the cache created. First invocation returns successful (201), second invocation returns conflict (409) which is ok, then the third invocation returns another successful status (201) which is incorrect. All succeeding calls are correct, which returns 409 consistently

When deleting a cache using the method ‘deleteCache’, it takes two invocations to get it deleted, First invocation returns successful status (200), second invocation still returns successful (200) which is incorrect, and all succeeding calls returns no URL (404) which is correct, and is being returned consistently afterwards.

Please refer to the codes below for more details.

Thanks! Chris

import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable;

import net.sf.ehcache.Element;

import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.DeleteMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.commons.io.IOUtils;

. . .

public void createCache(String cacheServerURL, String cacheName) throws CacheException \{
	String url = cacheServerURL + SEPARATOR + cacheName;
	PutMethod putMethod = new PutMethod(url);
	configureMethod(putMethod);
	int status = -1;
	try \{
		status = httpClient.executeMethod(putMethod);
		log("create cache status: " +status);
		if (status != HttpStatus.SC\_CREATED) \{
			throw new CacheException(status);
		\}
	\} catch (CacheException ce) \{
		throw ce;
	\} catch (Exception e) \{
		throw new CacheException(e);
	\} finally \{
		putMethod.releaseConnection();
	\}
\}

public void deleteCache(String cacheServerURL, String cacheName) throws CacheException \{
	String url = cacheServerURL + SEPARATOR + cacheName;
	DeleteMethod deleteMethod = new DeleteMethod(url);
	configureMethod(deleteMethod);
	int status = -1;
	try \{
		status = httpClient.executeMethod(deleteMethod);
		log("delete cache status: " +status);
		if (status != HttpStatus.SC\_OK) \{
			throw new CacheException(status);
		\}
	\} catch (CacheException ce) \{
		throw ce;
	\} catch (Exception e) \{
		throw new CacheException(e);
	\} finally \{
		deleteMethod.releaseConnection();
	\}
\}

Comments

Fiona OShea 2011-02-22

MOving unresolved P2 jiras to Ulloa - to be reviewed by Chris, Fiona, Greg soon