Skip to content
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

SpEL Collection Selection: "selectionExpression" with method invocation pushes root object as active context instead of current item [SPR-12035] #16651

Closed
spring-issuemaster opened this issue Jul 26, 2014 · 5 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Jul 26, 2014

Artem Bilan opened SPR-12035 and commented

See reference URL.
The root of the issue is here MethodReference:

// Make the root object the active context again for evaluating the parameter expressions
			try {
				state.pushActiveContextObject(state.getRootContextObject());
				arguments[i] = this.children[i].getValueInternal(state).getValue();
			}

Is it intentional? Or can we overcome it somehow?

Thanks,
Artem


Reference URL: http://stackoverflow.com/questions/24556122/spel-spring-expression-language-collection-selection-calling-methods-functions

Issue Links:

  • #15050 Collection selection and the use of #this
  • #17647 In SPEL projection expression, #this as the same value as #root

Referenced from: commits 91ed5b6

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 27, 2014

Juergen Hoeller commented

Andy Clement, what's your take on this?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 28, 2014

Artem Bilan commented

One more point on the matter:
Seems for me these expressions are equal:
foo.method(bar), foo.method(#this.bar), foo.method(#root.bar),
if we have only one level context.
In case of Collection Selection/Projection with this fix it would be, if want get deal with #roo

list.?[foo.method(#root.bar)]

, but if we don't specify the context object, it is a #this anyway:

list.?[foo.method(bar)]

should be equal to

`list.?[foo.method(#this.bar)]`

, when #this is a current item of Selection/Projection

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 27, 2014

Andy Clement commented

This is certainly an issue I want to tackle before getting into complex topic of compiling projection/selection.

I think state.pushActiveContextObject(state.getRootContextObject()); is wrong (or rather it is naive) and it should be more like state.pushActiveContextObject(state.getScopeRootContextObject());.

In the outer most scope, the scope root is #root but in an nested scope it may not be the same thing (e.g. inside a projection/selection). I'm going to explore with some test cases and look at the effect a change like this would have on existing expressions.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 27, 2014

Andy Clement commented

#15050 is also related to this.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 22, 2015

Andy Clement commented

Fixed by commit for #17647. Test cases based on this issue included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.