Skip to content

Commit 93bc9a8

Browse files
author
rstam
committed
CSHARP-905: Fix ParallelScan feature detection when connected to mongos.
1 parent 5fc89c0 commit 93bc9a8

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

MongoDB.Driver/Communication/FeatureDetection/FeatureContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class FeatureContext
2323
private MongoServerBuildInfo _buildInfo;
2424
private MongoConnection _connection;
2525
private IsMasterResult _isMasterResult;
26-
private MongoServerInstance _serverInstance;
26+
private MongoServerInstanceType _serverInstanceType;
2727

2828
// public methods
2929
public MongoServerBuildInfo BuildInfo
@@ -44,10 +44,10 @@ public IsMasterResult IsMasterResult
4444
set { _isMasterResult = value; }
4545
}
4646

47-
public MongoServerInstance ServerInstance
47+
public MongoServerInstanceType ServerInstanceType
4848
{
49-
get { return _serverInstance; }
50-
set { _serverInstance = value; }
49+
get { return _serverInstanceType; }
50+
set { _serverInstanceType = value; }
5151
}
5252
}
5353
}

MongoDB.Driver/Communication/FeatureDetection/InstanceTypeDependency.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public InstanceTypeDependency(MongoServerInstanceType instanceType)
2929
// public methods
3030
public bool IsMet(FeatureContext context)
3131
{
32-
return context.ServerInstance.InstanceType == _instanceType;
32+
return context.ServerInstanceType == _instanceType;
3333
}
3434
}
3535
}

MongoDB.Driver/Communication/MongoServerInstance.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -628,20 +628,11 @@ private void LookupServerInformation(MongoConnection connection)
628628
isMasterResult = RunCommandAs<IsMasterResult>(connection, "admin", isMasterCommand);
629629

630630
MongoServerBuildInfo buildInfo;
631-
FeatureSet featureSet;
632631
try
633632
{
634633
var buildInfoCommand = new CommandDocument("buildinfo", 1);
635634
var buildInfoResult = RunCommandAs<CommandResult>(connection, "admin", buildInfoCommand);
636635
buildInfo = MongoServerBuildInfo.FromCommandResult(buildInfoResult);
637-
var featureContext = new FeatureContext
638-
{
639-
BuildInfo = buildInfo,
640-
Connection = connection,
641-
IsMasterResult = isMasterResult,
642-
ServerInstance = this
643-
};
644-
featureSet = new FeatureSetDetector().DetectFeatureSet(featureContext);
645636
}
646637
catch (MongoCommandException ex)
647638
{
@@ -651,7 +642,6 @@ private void LookupServerInformation(MongoConnection connection)
651642
throw;
652643
}
653644
buildInfo = null;
654-
featureSet = null;
655645
}
656646

657647
ReplicaSetInformation replicaSetInformation = null;
@@ -667,6 +657,15 @@ private void LookupServerInformation(MongoConnection connection)
667657
instanceType = MongoServerInstanceType.ShardRouter;
668658
}
669659

660+
var featureContext = new FeatureContext
661+
{
662+
BuildInfo = buildInfo,
663+
Connection = connection,
664+
IsMasterResult = isMasterResult,
665+
ServerInstanceType = instanceType
666+
};
667+
var featureSet = new FeatureSetDetector().DetectFeatureSet(featureContext);
668+
670669
var newServerInfo = new ServerInformation
671670
{
672671
BuildInfo = buildInfo,

0 commit comments

Comments
 (0)