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

Get best invoke method based on parameters #996

Merged
merged 4 commits into from
Jan 25, 2023
Merged

Conversation

jasmith-hs
Copy link
Contributor

I copied the code of BeanELResolver to make the licensing easier than integrating the code with JinjavaBeanELResolver.

Using java 17 (Oracle JDK 17.0.2, Eclipse Adoptium 17.0.3, and likely more) changes the order in which String.class.getMethods() returns methods, which causes the public String replace(char oldChar, char newChar) method to be invoked when calling BeanELResolver.invoke(context, "some string", "replace", null, new Object[]{"some", ""}). This makes the resulting string ␀ome ␀tring instead of string.

This PR makes it so that we check that the parameter types of the method we select are assignable from the input parameters. And if there are multiple methods that could work, pick the one that has the more specific parameter types.

Copy link
Contributor

@jboulter jboulter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Have we found this to be a problem with any other methods that we know of?

@jasmith-hs
Copy link
Contributor Author

I don't know of any other cases where it changed

@jasmith-hs jasmith-hs merged commit 52e83a9 into master Jan 25, 2023
@jasmith-hs jasmith-hs deleted the get-best-invoke-method branch January 25, 2023 17:35
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.

None yet

2 participants