Skip to content

Fix of race condition with TranslatorState.NonVisitableExpressions #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2024
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
1 change: 1 addition & 0 deletions ChangeLog/7.1.3_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[main] Addressed race condition issue with TranslatorState.NonVisitableExpressions
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public static Type Extract(BinaryExpression expression)
return key.EntityType.UnderlyingType;
}

var expr = VisitBinaryExpession(expression);
var expr = VisitBinaryExpression(expression);
if (expr.Type.IsSubclassOf(WellKnownOrmTypes.Entity)) {
return expr.Type;
}
throw new NotSupportedException(string.Format(Strings.ExCurrentTypeXIsNotSupported, expr.Type));
}

private static Expression VisitBinaryExpession(BinaryExpression binaryExpression)
private static Expression VisitBinaryExpression(BinaryExpression binaryExpression)
{
if (!(binaryExpression.Right is MemberExpression memberExpression)) {
throw new InvalidOperationException(string.Format(Strings.ExCantConvertXToY, binaryExpression.Type, typeof(MemberExpression)));
Expand Down
4 changes: 3 additions & 1 deletion Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ internal sealed partial class Translator : QueryableVisitor
private readonly TranslatorContext context;
private readonly bool tagsEnabled;

internal TranslatorState State { get; private set; } = TranslatorState.InitState;
internal TranslatorState State { get; private set; } = new(TranslatorState.InitState) {
NonVisitableExpressions = new()
};

protected override Expression VisitConstant(ConstantExpression c)
{
Expand Down
2 changes: 1 addition & 1 deletion Orm/Xtensive.Orm/Orm/Linq/TranslatorState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public TranslatorScope(Translator translator)


/// <summary>
/// Expessions that were constructed during original expression translation
/// Expressions that were constructed during original expression translation
/// and aim to replace original parts so they are avoidable to visit by Linq translator.
/// </summary>
/// <remarks>
Expand Down