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 context is wrong in method parameter resolution [SPR-6525] #11191

Closed
spring-projects-issues opened this issue Dec 6, 2009 · 9 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 6, 2009

Dave Syer opened SPR-6525 and commented

SpEL context is wrong in method parameter resolution. Instead of using the current context for the stack (which refers to the method target), parameters should have a current context equal to the context root. This test would fail in EvaluationTests():

@Test
public void testNestedMethod() {
     evaluate("placeOfBirth.doubleIt(inventions.length)", 18, Integer.class);
}

Affects: 3.0 RC3

Attachments:

Issue Links:

Referenced from: commits 33a7bbb

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 6, 2009

Dave Syer commented

Attached #11191.patch. I'll leave it up to Andy to decide if it has any side effects (the tests all pass).

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

I posted on spr-dev but that is waiting moderation.

Mark F mentioned this at spring one and I meant to look at it but ran out of time. The workaround is to qualify the reference in the parameter:

placeOfBirth.doubleIt(#root.inventions.length)

The behaviour should change as you suggest, but I'm inclined (because of the trivial workaround - if that does work!) to put it into 3.0.1 and 3.1.

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

In any case, please add a section to the reference manual covering "#root" in contrast to "#this".

Thanks,

Sam

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Yeuch. Ugly workaround for a really common use case. I think we should fix it, otherwise we are going to get a lot of support requests. Can't we just add the patch quickly and fix anything that crops up as a result in 3.0.1?

The workaround does work, by the way.

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

personally I prefer an RC to be an RC - so this would necessitate an RC4. but if everyone else thinks it should go in regardless and not require another RC I can be persuaded.

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

Probably also affects constructor invocation and function invocation

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

per Juergens comment, I'll look at this tomorrow. I will look at constructors and function invocation too.

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

test and fix (per Dave's patch) is in. Added extra tests for function invocation, ctor invocation and a combined method/function invocation.

Also added the, err, 'secret' #root to the docs.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 3, 2012

Stevo Slavić commented

#10255 duplicates this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants