Details
-
Bug
-
Resolution: Won't Fix
-
Major
-
2.3.2
-
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.