You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "kylin (JIRA)" <ji...@apache.org> on 2007/04/29 04:23:15 UTC

[jira] Created: (CHAIN-37) The problem of org.apache.commons.chain.impl.ChainBase.execute

The problem of org.apache.commons.chain.impl.ChainBase.execute
--------------------------------------------------------------

                 Key: CHAIN-37
                 URL: https://issues.apache.org/jira/browse/CHAIN-37
             Project: Commons Chain
          Issue Type: Bug
    Affects Versions: 1.1, 1.0
            Reporter: kylin
            Priority: Critical


The ChainBase.execute metod is not thread safety,I Change the code like that:

// Execute the commands in this list until one returns true
        // or throws an exception
        boolean saveResult = false;
        Exception saveException = null;
        int i = 0;
        int n = commands.length;
        for (i = 0; i < n; i++) {
            try {
            	
            	Command command = (Command)commands[i];
            	
            	Command newCommand  = ((Command)commands[i].getClass().newInstance());
            	
            	PropertyUtils.copyProperties(newCommand,command);
            	
                saveResult = newCommand.execute(context);
                
                if (saveResult) {
                    break;
                }
            } catch (Exception e) {
                saveException = e;
                break;
            }
        }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (CHAIN-37) The problem of org.apache.commons.chain.impl.ChainBase.execute

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CHAIN-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492564 ] 

Niall Pemberton commented on CHAIN-37:
--------------------------------------

True its not thread safe - but AFAIK thats the way it was designed, using singleton instances of the Command - rather than creating a new instance for each execution as in your proposal. ChainBase is a convenience implementation, you're free to re-use and create your own implementation with the behaviour you want - I think we should close this as "WONT FIX" though

> The problem of org.apache.commons.chain.impl.ChainBase.execute
> --------------------------------------------------------------
>
>                 Key: CHAIN-37
>                 URL: https://issues.apache.org/jira/browse/CHAIN-37
>             Project: Commons Chain
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1
>            Reporter: kylin
>            Priority: Critical
>
> The ChainBase.execute metod is not thread safety,I Change the code like that:
> // Execute the commands in this list until one returns true
>         // or throws an exception
>         boolean saveResult = false;
>         Exception saveException = null;
>         int i = 0;
>         int n = commands.length;
>         for (i = 0; i < n; i++) {
>             try {
>             	
>             	Command command = (Command)commands[i];
>             	
>             	Command newCommand  = ((Command)commands[i].getClass().newInstance());
>             	
>             	PropertyUtils.copyProperties(newCommand,command);
>             	
>                 saveResult = newCommand.execute(context);
>                 
>                 if (saveResult) {
>                     break;
>                 }
>             } catch (Exception e) {
>                 saveException = e;
>                 break;
>             }
>         }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (CHAIN-37) The problem of org.apache.commons.chain.impl.ChainBase.execute

Posted by "Martin Cooper (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CHAIN-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Cooper resolved CHAIN-37.
--------------------------------

    Resolution: Won't Fix

Niall is correct. This is as designed.

> The problem of org.apache.commons.chain.impl.ChainBase.execute
> --------------------------------------------------------------
>
>                 Key: CHAIN-37
>                 URL: https://issues.apache.org/jira/browse/CHAIN-37
>             Project: Commons Chain
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1
>            Reporter: kylin
>            Priority: Critical
>
> The ChainBase.execute metod is not thread safety,I Change the code like that:
> // Execute the commands in this list until one returns true
>         // or throws an exception
>         boolean saveResult = false;
>         Exception saveException = null;
>         int i = 0;
>         int n = commands.length;
>         for (i = 0; i < n; i++) {
>             try {
>             	
>             	Command command = (Command)commands[i];
>             	
>             	Command newCommand  = ((Command)commands[i].getClass().newInstance());
>             	
>             	PropertyUtils.copyProperties(newCommand,command);
>             	
>                 saveResult = newCommand.execute(context);
>                 
>                 if (saveResult) {
>                     break;
>                 }
>             } catch (Exception e) {
>                 saveException = e;
>                 break;
>             }
>         }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (CHAIN-37) The problem of org.apache.commons.chain.impl.ChainBase.execute

Posted by "kylin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CHAIN-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492567 ] 

kylin commented on CHAIN-37:
----------------------------

OK,but I don't think so,if you just for singleton pattern, then take this problem , I think use singleton pattern is unseemliness,I believe other users have same problem.



> The problem of org.apache.commons.chain.impl.ChainBase.execute
> --------------------------------------------------------------
>
>                 Key: CHAIN-37
>                 URL: https://issues.apache.org/jira/browse/CHAIN-37
>             Project: Commons Chain
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1
>            Reporter: kylin
>            Priority: Critical
>
> The ChainBase.execute metod is not thread safety,I Change the code like that:
> // Execute the commands in this list until one returns true
>         // or throws an exception
>         boolean saveResult = false;
>         Exception saveException = null;
>         int i = 0;
>         int n = commands.length;
>         for (i = 0; i < n; i++) {
>             try {
>             	
>             	Command command = (Command)commands[i];
>             	
>             	Command newCommand  = ((Command)commands[i].getClass().newInstance());
>             	
>             	PropertyUtils.copyProperties(newCommand,command);
>             	
>                 saveResult = newCommand.execute(context);
>                 
>                 if (saveResult) {
>                     break;
>                 }
>             } catch (Exception e) {
>                 saveException = e;
>                 break;
>             }
>         }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (CHAIN-37) The problem of org.apache.commons.chain.impl.ChainBase.execute

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CHAIN-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492570 ] 

Niall Pemberton commented on CHAIN-37:
--------------------------------------

Its not a problem for me and hasn't been raised as an issue on the Struts list - which uses this implementation at its core in its ComposableRequestProcessor. Creating a new instance for each execution in that scenrio would impact performance for web applications with many users - so IMO this implementation should not be changed. As I said before though - creating your own implementation with your desired behaviour would be very easy since you can just extend ChainBase and implement your own version of the execute method. If you think it useful to others you could always submit it for inclusion in Commons Chain. Alternatively perhaps adding a new property to ChainBase so that this beahvour could be configurable (but retaining backwards compatibility with existing behaviour as the default) would also work. If you're interested in developing that, then please submit a patch (preferrably with test cases).

> The problem of org.apache.commons.chain.impl.ChainBase.execute
> --------------------------------------------------------------
>
>                 Key: CHAIN-37
>                 URL: https://issues.apache.org/jira/browse/CHAIN-37
>             Project: Commons Chain
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1
>            Reporter: kylin
>            Priority: Critical
>
> The ChainBase.execute metod is not thread safety,I Change the code like that:
> // Execute the commands in this list until one returns true
>         // or throws an exception
>         boolean saveResult = false;
>         Exception saveException = null;
>         int i = 0;
>         int n = commands.length;
>         for (i = 0; i < n; i++) {
>             try {
>             	
>             	Command command = (Command)commands[i];
>             	
>             	Command newCommand  = ((Command)commands[i].getClass().newInstance());
>             	
>             	PropertyUtils.copyProperties(newCommand,command);
>             	
>                 saveResult = newCommand.execute(context);
>                 
>                 if (saveResult) {
>                     break;
>                 }
>             } catch (Exception e) {
>                 saveException = e;
>                 break;
>             }
>         }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org