You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Aaron Brown (JIRA)" <ji...@apache.org> on 2007/09/11 03:16:34 UTC

[jira] Created: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

ObjectFactory.buildResult not correctly configuring Result instance properties
------------------------------------------------------------------------------

                 Key: WW-2170
                 URL: https://issues.apache.org/struts/browse/WW-2170
             Project: Struts 2
          Issue Type: Bug
          Components: Actions
    Affects Versions: 2.0.9
         Environment: WIndows Server 2003
            Reporter: Aaron Brown


Hi, I think I have stumbled across a bug in the ObjectFactory. 

ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 

If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	

However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 

For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.

Here is my Action class:
@Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
public class JsonAction extends ActionSupport  {
	 
	@SMDMethod
    	public String getName(String client) {
        return "testName";
    	}
}


If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown resolved WW-2170.
---------------------------

    Resolution: Fixed
      Assignee: Don Brown

Well, in the current code, your change has been made (by me it seems), so how warnings will be printed, but the property setting will continue.  I still think this should be handled better, but it should be fine for now since it works the way we want but will just print out warnings in the semi-rare case the result uses the parameters for something they weren't intended for, which at this point, it seems only to be the ServletActionRedirectResult.

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42183 ] 

aaronbrown edited comment on WW-2170 at 9/11/07 3:42 PM:
----------------------------------------------------------

Don't use this one...non standard code formatting.

      was (Author: aaronbrown):
    Please use this patch! (sorry)
  
> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2170:
-----------------------------

    Fix Version/s:     (was: 2.0.11)
                   2.0.12

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.12
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Brown updated WW-2170:
----------------------------

    Attachment: ww-2170.patch

I'm retarded...here is the patch with the Struts 2 code formatting rather than my company's formatting. Habitual keystrokes get you on occasion. Sorry for the confusion!

thanks,
aaron

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Brad Cupit (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43598#action_43598 ] 

Brad Cupit commented on WW-2170:
--------------------------------

yay! it should be really really easy (not including the test, I think it's just deleting 6 characters)  :-)

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Brown updated WW-2170:
----------------------------

    Attachment: ww-2170.patch

Patch for project created from project root, includes proposed fix and test case.

Proposed fix is simply to call to a more restrictive setProperties() on the OgnlUtils class which prevents exceptions from being thrown during binding.

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Rene Gielen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43597#action_43597 ] 

Rene Gielen commented on WW-2170:
---------------------------------

If time permits, I'm planning to do a backport of some issues for a Struts 2.0 maintainance release. This one would definitely make it into the port.

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2170:
-----------------------------

    Flags: [Patch]

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Guillaume Bilodeau (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43587#action_43587 ] 

Guillaume Bilodeau commented on WW-2170:
----------------------------------------

Is there any chance this fix could be backported to a 2.0.x release?

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42184 ] 

aaronbrown edited comment on WW-2170 at 9/11/07 3:42 PM:
----------------------------------------------------------

I'm habitual...here is the patch with the Struts 2 code formatting rather than my company's formatting. Sorry for the confusion!

thanks,
aaron

      was (Author: aaronbrown):
    I'm retarded...here is the patch with the Struts 2 code formatting rather than my company's formatting. Habitual keystrokes get you on occasion. Sorry for the confusion!

thanks,
aaron
  
> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Brown updated WW-2170:
----------------------------

    Attachment: ww-2170.patch

Please use this patch! (sorry)

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Aaron Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42182 ] 

aaronbrown edited comment on WW-2170 at 9/11/07 3:43 PM:
----------------------------------------------------------

Patch for project created from project root, includes proposed fix and test case.

Proposed fix is simply to call to a more restrictive setProperties() on the OgnlUtils class which prevents exceptions from being thrown during binding.

Don't use this one...non standard code formatting. See newest attachment.

      was (Author: aaronbrown):
    Patch for project created from project root, includes proposed fix and test case.

Proposed fix is simply to call to a more restrictive setProperties() on the OgnlUtils class which prevents exceptions from being thrown during binding.
  
> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43064#action_43064 ] 

Don Brown commented on WW-2170:
-------------------------------

The reason exceptions are ignored is result parameters are not always meant to be applied as setters.  For example, the redirect results programatically access the parameters and interpret them as parameters to set on the redirect request.  Therefore, there is no corresponding setter and OGNL will throw an exception.  Certainly, the current implementation is ideal, but just having exceptions thrown is not the solution.  Perhaps we let results declare themselves as supporting "strict" parameter assignments? 

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2170:
-----------------------------

    Fix Version/s: 2.0.11

If you come up with a proposed fix, please post the patch to this ticket.

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>             Fix For: 2.0.11
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2170) ObjectFactory.buildResult not correctly configuring Result instance properties

Posted by "Brad Cupit (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43593#action_43593 ] 

Brad Cupit commented on WW-2170:
--------------------------------

I agree! Please backport to a 2.0.x release!

> ObjectFactory.buildResult not correctly configuring Result instance properties
> ------------------------------------------------------------------------------
>
>                 Key: WW-2170
>                 URL: https://issues.apache.org/struts/browse/WW-2170
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.0.9
>         Environment: WIndows Server 2003
>            Reporter: Aaron Brown
>            Assignee: Don Brown
>             Fix For: 2.1.1
>
>         Attachments: ww-2170.patch, ww-2170.patch, ww-2170.patch
>
>
> Hi, I think I have stumbled across a bug in the ObjectFactory. 
> ObjectFactory.buildResult() invokes OgnlUtil.setProperties(resultConfig.getParams(), result, extraContext, true) to populate a Result instance with a parameter map. In addition, the call to OgnlUtil.setProperties forces exceptions to be thrown when necessary, by setting the last parameter in the method call to 'true'. 
> If an exception is thrown, it is caught by the ObjectFactory and logged with a level of DEBUG. Further, in the ObjectFactory.buildResult() method the following comment appears: "ognl exceptions could be thrown and be ok if, for example, the result uses parameters in ways other than as properties for the result object."	
> However, throwing exceptions is not ok. The Ognl.setProperties method will stop execution if an exception is thrown. As such, it is possible that not all properties specified in the ResultConfig parameter map will be set on the Result instance. 
> For example, I am trying to set a property on a JSONResult class. However, the ResultConfig parameter map has a 'location' property in addition to the property in my Result action annotation. (I havne't tracked down where this location is being set in the ResultConfig). The 'location' property is the first thing that OgnlUtils tries to set and an error is thrown. Loop iteration stops, and the "enableSMD" property in the params map is ignored and the Result class is incorrectly configured.
> Here is my Action class:
> @Result(name = "success", value = "", type = JSONResult.class, params = {"enableSMD", "true"}) 
> public class JsonAction extends ActionSupport  {
> 	 
> 	@SMDMethod
>     	public String getName(String client) {
>         return "testName";
>     	}
> }
> If all you want to do is log an erroneous attempt to set a property, why are you throwing exceptions? The OgnlUtil.internalSetProperty() method will do that for you if it configured not to throw exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.