Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-102

Client.get() returns null values when using CouchbaseConnectionFactoryBuilder

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1dp
    • Fix Version/s: None
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None
    • Environment:
      OSX
      Couchbase Server 2.0.0dp4r-730-rel
      Java Client 1.1-dp

      Description

      Java client 1.1-dp seems to have a problem using CouchbaseConnectionFactoryBuilder. Client.get() returns null values regardless of whether a key exists or not. Java client 1.0.3 doesn't have the problem.

      With 1.1-dp, if I set up a client like so:

      URI base = new URI(String.format("http://%s:8091/pools", server));
      List<URI> baseURIs = new ArrayList<URI>();
      baseURIs.add(base);
      CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
      cfb.setOpTimeout(10000);
      cfb.setOpQueueMaxBlockTime(10000);
      CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(baseURIs, bucket, "", "");
      CouchbaseClient client = new CouchbaseClient(cf);

      then try to get a key like so:

      getFuture = client.asyncGet(key);
      value = (String) getFuture.get(); // value is null

      the .get() doesn't fail but the returned value is null.

      However, if I set up the 1.1-dp client like so, using just CouchbaseConnectionFactory:

      URI base = new URI(String.format("http://%s:8091/pools", server));
      List<URI> baseURIs = new ArrayList<URI>();
      baseURIs.add(base);
      CouchbaseConnectionFactory cf = new CouchbaseConnectionFactory(baseURIs, bucket, "");
      CouchbaseClient client = new CouchbaseClient(cf);
      getFuture = client.asyncGet(key);
      value = (String) getFuture.get(); // value is not null and contains the document for the key

      I want to use CouchbaseConnectionFactoryBuilder because I'm doing a bulk import of millions of documents and I need the timeout/blocking behaviour to prevent swamping the client.

      Java client 1.0.3 works correctly - using CouchbaseConnectionFactoryBuilder to build connection factories and clients results in the correct behaviour.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Tim Pedersen Tim Pedersen added a comment -

        This also affects getting documents from queries/views see JCBC-103

        Show
        Tim Pedersen Tim Pedersen added a comment - This also affects getting documents from queries/views see JCBC-103
        Hide
        rags Raghavan Srinivas (Inactive) added a comment -

        I tried to reproduce this with the latest builds as below and I don't see this error. I see the following relevant output.

        {"presidency":"1","name":"George Washington","wikipedia_entry":"http://en.wikipedia.org/wiki/George_Washington","took_office":"1789","left_office":"1797","party":"Independent","portrait":"GeorgeWashington.jpg","thumbnail":"thmb_GeorgeWashington.jpg","home_state":"Virginia","type":"president"}

        value =

        {"presidency":"1","name":"George Washington","wikipedia_entry":"http://en.wikipedia.org/wiki/George_Washington","took_office":"1789","left_office":"1797","party":"Independent","portrait":"GeorgeWashington.jpg","thumbnail":"thmb_GeorgeWashington.jpg","home_state":"Virginia","type":"president"}

        import java.net.URI;
        import java.util.ArrayList;
        import java.util.List;

        import com.couchbase.client.CouchbaseClient;
        import com.couchbase.client.CouchbaseConnectionFactory;
        import com.couchbase.client.CouchbaseConnectionFactoryBuilder;

        import net.spy.memcached.internal.GetFuture;

        public class cfb {

        public static void main(String args[]) {
        try

        { URI base = new URI( String.format("http://%s:8091/pools","localhost")); List<URI> baseURIs = new ArrayList<URI>(); baseURIs.add(base); // baseURIs.add(fallback); CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder(); // wait up to 10 seconds for an operation to succeed cfb.setOpTimeout(10000); CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(baseURIs, "default", "", ""); // new // CouchbaseConnectionFactory(baseURIs, "default", ""); CouchbaseClient client = new CouchbaseClient(cf); System.out.println(client.get("1")); GetFuture getFuture = client.asyncGet("1"); String value = (String) getFuture.get(); System.out.println("value = " + value); }

        catch (Exception e)

        { System.err.println("Error connecting to Couchbase: " + e.getMessage()); }

        finally

        { System.exit(0); }

        }
        }

        Show
        rags Raghavan Srinivas (Inactive) added a comment - I tried to reproduce this with the latest builds as below and I don't see this error. I see the following relevant output. {"presidency":"1","name":"George Washington","wikipedia_entry":"http://en.wikipedia.org/wiki/George_Washington","took_office":"1789","left_office":"1797","party":"Independent","portrait":"GeorgeWashington.jpg","thumbnail":"thmb_GeorgeWashington.jpg","home_state":"Virginia","type":"president"} value = {"presidency":"1","name":"George Washington","wikipedia_entry":"http://en.wikipedia.org/wiki/George_Washington","took_office":"1789","left_office":"1797","party":"Independent","portrait":"GeorgeWashington.jpg","thumbnail":"thmb_GeorgeWashington.jpg","home_state":"Virginia","type":"president"} import java.net.URI; import java.util.ArrayList; import java.util.List; import com.couchbase.client.CouchbaseClient; import com.couchbase.client.CouchbaseConnectionFactory; import com.couchbase.client.CouchbaseConnectionFactoryBuilder; import net.spy.memcached.internal.GetFuture; public class cfb { public static void main(String args[]) { try { URI base = new URI( String.format("http://%s:8091/pools","localhost")); List<URI> baseURIs = new ArrayList<URI>(); baseURIs.add(base); // baseURIs.add(fallback); CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder(); // wait up to 10 seconds for an operation to succeed cfb.setOpTimeout(10000); CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(baseURIs, "default", "", ""); // new // CouchbaseConnectionFactory(baseURIs, "default", ""); CouchbaseClient client = new CouchbaseClient(cf); System.out.println(client.get("1")); GetFuture getFuture = client.asyncGet("1"); String value = (String) getFuture.get(); System.out.println("value = " + value); } catch (Exception e) { System.err.println("Error connecting to Couchbase: " + e.getMessage()); } finally { System.exit(0); } } }
        Hide
        rags Raghavan Srinivas (Inactive) added a comment -

        Based on my comments earlier during the day, I could not reproduce.

        Please reopen if you stil see the same issue or if the steps I am not following are not exactly the same?

        Show
        rags Raghavan Srinivas (Inactive) added a comment - Based on my comments earlier during the day, I could not reproduce. Please reopen if you stil see the same issue or if the steps I am not following are not exactly the same?

          People

          • Assignee:
            rags Raghavan Srinivas (Inactive)
            Reporter:
            Tim Pedersen Tim Pedersen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes