java driver : lisKeys() returned also deleted keys

Andrea Campolonghi acampolonghi at gmail.com
Sat Nov 20 13:02:57 EST 2010


I am having this issues with the java driver :
https://github.com/krestenkrab/riak-java-pb-client

After deleting a key the listKeys method still return it.
The following test case put and delete one simple key and fails when
counting the listKeys item.

Any Suggestion?

   public class RiakCacheTest extends TestCase {

 private RiakClient rc;

private String host = "172.16.194.134";

private int port = 8087;

private String bucket = "bucket";

  @Override

protected void setUp() throws Exception {

 rc = new RiakClient(this.host,this.port);

 rc.setClientID(this.getClass().toString());

}

  public void testRemove(){

 String key = "key";

 String value = "Andrea";

  RiakObject obj = new RiakObject(this.bucket, key, value);

  try{

 this.rc.store(obj);

 assertTrue(getValue(key).equals(value));

 assertEquals(keys().size(),1);

   this.rc.delete(this.bucket, key);

 assertNull(getValue(key));

 assertEquals(keys().size(),0);

   }catch(IOException e){

 e.printStackTrace();

 }

  }

 private String getValue(String key){

 String fetched = "";

 try{

 RiakObject[] ros = this.rc.fetch(this.bucket, key);

 for(RiakObject ro : ros){

  return ro.getValue().toStringUtf8();

 }

 }catch(IOException e){

 e.printStackTrace();

 }

 return null;

}


 private List keys() {

 ArrayList<String> result = new ArrayList<String>();

 ByteString bucket = ByteString.copyFromUtf8(this.bucket);

  try{

  KeySource keys = this.rc.listKeys(bucket);

  while(keys.hasNext()){

  String key = keys.next().toStringUtf8();

  result.add(key);

  }

 }catch(IOException e){

 e.printStackTrace();

 }

 return result;

}


}

-- 
Andrea Campolonghi

Cell : +39 347 2298435
acampolonghi at gmail.com
andrea at andreacfm.com
http://www.andreacfm.com

Railo Team
andrea at getrailo.org
http://getrailo.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20101120/932bb9d5/attachment.html>


More information about the riak-users mailing list