gets never completes operation JAVA API
Tue, 08/14/2012 - 01:32
Hi,
I have a problem with gets() never completing or sending an error when trying to get a key that does not exist.
The following code has been tested with API 1.0 and 1.1
public Job getJob(JobType jobType) {
String key = Job.getKey(jobType);
System.out.println("get job "+key);
String json = null;
CASValue<Object> cas = client.gets(key);
System.out.println("here");
System.out.println("get cas "+cas.getCas());
json = (String) cas.getValue();
System.out.println("Object Json:\n" + json);
... // some more stuff here
return job;
}The console log prints :
get job JOB-SendTimeoutWarnings
here
and never throws an error or finishes the operation. I know the key is missing I would expect it to throw some KeyMissing exception or return null.
is this expected behavior?
Thanks
Sun, 08/19/2012 - 10:16
Hi Mchael,
Thanks, I am developing against version 2 for OS X.
I tried with asyncGets, with similar results,
I did
asyncGet(key) cas = future.get(5,TimeUnit.SECONDS); print something... cas.getValue() print something..
it gets stuck in the cas.getValue() operation or alternatively in cas.getCas()
I did manage to solve the problem by doing
CASValue<Object> cas = client.gets(key);
System.out.println("here");
if(cas==null) return null;
System.out.println("There");
System.out.println("get cas "+cas.getValue());but its undocumented usage and might brake in future releases of the API I suppose, I saw it being used like that in the set example somewhere
Thanks,
Yuval
Doing "nothing" and just hanging the application is normally not considered as expected behavior ;)!
It would be great if you could two things:
- Please tell us against which version of couchbase you are developing
- Can you try the same with asyncGets and see if the future object times out or produces the same behavior? You can see the docs for it here at the bottom: http://www.couchbase.com/docs/couchbase-sdk-java-1.0/couchbase-sdk-java-...
Thanks, Michael