Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-1156

Queries fail if BucketConfiguration.PoolConfiguration.ClientConfiguration is null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Major
    • backlog-2.0, .backlog
    • 2.3.2
    • library
    • None

    Description

      This should probably be fixed in the core SDK but IMO, the Linq Provider needs to have better fault handling for it.

      lets assume the following code

      var config = new ClientConfiguration()
      {
          BucketConfigs = new Dictionary<string, BucketConfiguration>
          {
              {"MyBucket", new BucketConfiguration
              {
                  BucketName = "MyBucket",
                  Username = "Foo",
                  Password = "Bar",
                  PoolConfiguration = new PoolConfiguration
                  {
                        MinSize = 1,
                        MaxSize = 10,
                  }
              } }
          }
      };
      var cluster = new Cluster(config);
      var bucket = cluster.OpenBucket("MyBucket");
      var context = new BucketContext(bucket);
      That code will throw a null ref exception when you try to query the database.
      This is because of this line:
       
              //BucketContext.cs
       
              public ClientConfiguration Configuration
              {
                  get { return _bucket.Configuration.PoolConfiguration.ClientConfiguration; }
              }
      
      

      Where ClientConfiguration is null
      The client config is null because there is a back-reference from PoolConfiguration to ClientConfiguration.

      In order to fix the issue, one need to set that back-reference manually:

      config.BucketConfig["MyBucket"].PoolConfiguration = config;

      This was somewhat of a pain to find, but IMO, the Linq provider could throw early with a clear error message if the bucket.Configuration.PoolConfiguration.ClientConfiguration is null already when clreading the BucketContext.

      And the real fix should probably be to make the SDK handle all the back-references internally.
      Because as it is right now, it's sort of shaky if the end user needs to wire it up themselves. even possible to point it back to a completely different config.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            jmorris Jeff Morris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty