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

OgnlRuntime#getReadMethod() returns null if the method is a bridge method #104

Merged
merged 1 commit into from
Aug 17, 2020
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
6 changes: 0 additions & 6 deletions src/main/java/ognl/OgnlRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -3597,9 +3597,6 @@ public static Method getReadMethod(Class target, String name, Class[] argClasses

for (int i = 0; i < methods.length; i++)
{
if (!isMethodCallable(methods[i]))
continue;

if ((methods[i].getName().equalsIgnoreCase(name)
|| methods[i].getName().toLowerCase().equals("get" + name)
|| methods[i].getName().toLowerCase().equals("has" + name)
Expand All @@ -3617,9 +3614,6 @@ public static Method getReadMethod(Class target, String name, Class[] argClasses

for (int i = 0; i < methods.length; i++)
{
if (!isMethodCallable(methods[i]))
continue;

if (methods[i].getName().equalsIgnoreCase(name)
&& !methods[i].getName().startsWith("set")
&& !methods[i].getName().startsWith("get")
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/ognl/TestOgnlRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,4 +699,23 @@ public String testMethod (String element, int i) {
}
}

protected static class ProtectedParent {
public void setName(String name) {
}
public String getName() {
return "name";
}
}

public static class PublicChild extends ProtectedParent {
}

public void testSyntheticReadMethod() throws Exception {
assertNotNull(OgnlRuntime.getReadMethod(PublicChild.class, "name"));
}

public void testSyntheticWriteMethod() throws Exception {
assertNotNull(OgnlRuntime.getWriteMethod(PublicChild.class, "name"));
}

}