Skip to content

ReferenceNode throws KeyNotFoundException when CurrentObjectFactory wasn't provided in variables. #219

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

Conversation

kamilpitula
Copy link
Contributor

@kamilpitula kamilpitula commented Mar 16, 2022

After a change that replaced IDictionary with generic IDictionary<string, object> in EvaluationContext class, ReferenceNode throws KeyNotFoundException instead of using default context (non generic dictionaries return null when key does not exsist). I came across this bug when i was trying to resolve Spring expression like this: expression.GetValue(arg.ExpressionContext, arg.ExpressionVariables), where expression is of type IExpression. This forced me to add a line like this: arg.ExpressionVariables[Expression.ReservedVariableNames.RESERVEDPREFIX + "CurrentObjectFactory"] = ContextRegistry.GetContext(); in my code as a workaround.

I have added a check in ReferenceNode that verifies whether key is present in dictionary, and uses default context when it's not (as was initially intended I guess). I have also created some additional unit tests that cover cases I mentioned above.

@kamilpitula kamilpitula changed the title Reference node throws KeyNotFoundException when CurrentObjectFactory wasn't provided in variables. ReferenceNode throws KeyNotFoundException when CurrentObjectFactory wasn't provided in variables. Mar 16, 2022
@kamilpitula
Copy link
Contributor Author

kamilpitula commented Mar 17, 2022

@lahma
Hi, it seems that there is a problem with MSBuild in build-windows pipeline. Could you please take a look?

* change minimum .NET Framework target to 4.6.2
@lahma
Copy link
Collaborator

lahma commented Mar 18, 2022

@kamilpitula I'll have a look probably this evening, seems that build infra needs some updates.

@kamilpitula
Copy link
Contributor Author

@kamilpitula I'll have a look probably this evening, seems that build infra needs some updates.

Thanks!

@lahma
Copy link
Collaborator

lahma commented Mar 18, 2022

@kamilpitula if you rebase against main you should have latest build infra which is green against main.

@lahma lahma merged commit 9a45773 into spring-projects:main Mar 18, 2022
@lahma
Copy link
Collaborator

lahma commented Mar 18, 2022

Thank you!

@kamilpitula kamilpitula deleted the bugfix/ReferenceNode_ThrowsKeyNotFoundException branch March 18, 2022 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants