Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Microsoft.Azure.Cosmos/src/DocumentClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ internal partial class DocumentClient : IDisposable, IAuthorizationTokenProvider
private const bool DefaultEnableCpuMonitor = true;
private const string DefaultInitTaskKey = "InitTaskKey";

private static readonly char[] resourceIdOrFullNameSeparators = new char[] { '/' };
private static readonly char[] resourceIdSeparators = new char[] { '/', '\\', '?', '#' };

private readonly bool IsLocalQuorumConsistency = false;
private readonly bool isReplicaAddressValidationEnabled;

Expand Down Expand Up @@ -2165,7 +2168,7 @@ private async Task<ResourceResponse<DocumentCollection>> RestoreDocumentCollecti
string databaseLink = PathsHelper.GetDatabasePath(sourceDocumentCollectionLink);
if (PathsHelper.TryParsePathSegments(databaseLink, out isFeed, out resourceTypeString, out resourceIdOrFullName, out isNameBased) && isNameBased && !isFeed)
{
string[] segments = resourceIdOrFullName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] segments = resourceIdOrFullName.Split(resourceIdOrFullNameSeparators, StringSplitOptions.RemoveEmptyEntries);
dbsId = segments[segments.Length - 1];
}
else
Expand All @@ -2176,7 +2179,7 @@ private async Task<ResourceResponse<DocumentCollection>> RestoreDocumentCollecti
string sourceCollId;
if (PathsHelper.TryParsePathSegments(sourceDocumentCollectionLink, out isFeed, out resourceTypeString, out resourceIdOrFullName, out isNameBased) && isNameBased && !isFeed)
{
string[] segments = resourceIdOrFullName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] segments = resourceIdOrFullName.Split(resourceIdOrFullNameSeparators, StringSplitOptions.RemoveEmptyEntries);
sourceCollId = segments[segments.Length - 1];
}
else
Expand Down Expand Up @@ -6811,7 +6814,7 @@ internal void ValidateResource(string resourceId)
{
if (!string.IsNullOrEmpty(resourceId))
{
int match = resourceId.IndexOfAny(new char[] { '/', '\\', '?', '#' });
int match = resourceId.IndexOfAny(resourceIdSeparators);
if (match != -1)
{
throw new ArgumentException(string.Format(
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Linq/ExpressionToSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ internal static SqlScalarExpression VisitScalarExpression(Expression expression,
{
return ExpressionToSql.VisitScalarExpression(
expression,
new ReadOnlyCollection<ParameterExpression>(new ParameterExpression[] { }),
new ReadOnlyCollection<ParameterExpression>(Array.Empty<ParameterExpression>()),
context);
}

Expand Down
4 changes: 3 additions & 1 deletion Microsoft.Azure.Cosmos/src/Routing/LocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Microsoft.Azure.Cosmos.Routing
/// </summary>
internal static class LocationHelper
{
private static readonly char[] hostSeparators = new char[] { '.' };

/// <summary>
/// For example, for https://contoso.documents.azure.com:443/ and "West US", this will return https://contoso-westus.documents.azure.com:443/
/// NOTE: This ONLY called by client first boot when the input endpoint is not available.
Expand All @@ -21,7 +23,7 @@ internal static Uri GetLocationEndpoint(Uri serviceEndpoint, string location)
// Split the host into 2 parts seperated by '.'
// For example, "contoso.documents.azure.com" is separated into "contoso" and "documents.azure.com"
// If the host doesn't contains '.', this will return the host as is, as the only element
string[] hostParts = builder.Host.Split(new char[] { '.' }, 2);
string[] hostParts = builder.Host.Split(hostSeparators, 2);

if (hostParts.Length != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Cosmos.Telemetry.Collector

internal class TelemetryCollector : ITelemetryCollector
{
private static readonly char[] pathSeparators = new char[] { '/' };

private readonly ClientTelemetry clientTelemetry = null;
private readonly ConnectionPolicy connectionPolicy = null;

Expand Down Expand Up @@ -69,7 +71,7 @@ public void CollectOperationAndNetworkInfo(Func<TelemetryInformation> functionFo

private static void GetDatabaseAndCollectionName(string path, out string databaseName, out string collectionName)
{
string[] segments = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] segments = path.Split(pathSeparators, StringSplitOptions.RemoveEmptyEntries);

PathsHelper.ParseDatabaseNameAndCollectionNameFromUrlSegments(segments, out databaseName, out collectionName);
}
Expand Down
Loading