commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lon Varscsak (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (OGNL-250) OnglRuntime getMethodValue fails to find method matching propertyName
Date Thu, 27 Aug 2015 18:56:45 GMT

    [ https://issues.apache.org/jira/browse/OGNL-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14717291#comment-14717291
] 

Lon Varscsak edited comment on OGNL-250 at 8/27/15 6:55 PM:
------------------------------------------------------------

I'm not sure what's the best way to give you what you want, but this demonstrates it (let
me know if you want in a different format):

{{public class OgnlTest {
	public static void main(String[] args) {
		try {
			System.out.println(Ognl.getValue("testProperty", new TestObject()));
		} catch (OgnlException e) {
			System.out.println("Ognl couldn't find TestObject.testProperty()");
		}
	}
	
	public static class TestObject {
		private String testProperty = "Hello World!";
		
		public String testProperty() {
			return testProperty;
		}
	}
}}}



was (Author: varscsak):
I'm not sure what's the best way to give you what you want, but this demonstrates it (let
me know if you want in a different format):

public class OgnlTest {
	public static void main(String[] args) {
		try {
			System.out.println(Ognl.getValue("testProperty", new TestObject()));
		} catch (OgnlException e) {
			System.out.println("Ognl couldn't find TestObject.testProperty()");
		}
	}
	
	public static class TestObject {
		private String testProperty = "Hello World!";
		
		public String testProperty() {
			return testProperty;
		}
	}

}


> OnglRuntime getMethodValue fails to find method matching propertyName
> ---------------------------------------------------------------------
>
>                 Key: OGNL-250
>                 URL: https://issues.apache.org/jira/browse/OGNL-250
>             Project: Commons OGNL
>          Issue Type: Bug
>          Components: Core Runtime
>            Reporter: Lon Varscsak
>         Attachments: test.tar.gz
>
>
> In OnglRuntime's getMethodValue method it attempts first to get the "get" method, if
this fails, it trys to getReadMethod, which fails to find a method even though there is one
matching the propertyName.
> I believe that:
>         if ( method == null )
>         {
>             method = getReadMethod( targetClass, propertyName, 0 );
>         }
> Should be:
>         if ( method == null )
>         {
>             method = getReadMethod( targetClass, propertyName, -1);
>         }
> Since the getReadMethod does not return any method if you pass in 0 (the check is <
0 or > 0)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message