You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2009/10/23 13:17:59 UTC

[jira] Created: (EXEC-42) Tutorial should include example for asynchronous handling

Tutorial should include example for asynchronous handling
---------------------------------------------------------

                 Key: EXEC-42
                 URL: https://issues.apache.org/jira/browse/EXEC-42
             Project: Commons Exec
          Issue Type: Improvement
            Reporter: Konrad Windszus


I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:

- How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
- How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
- How to force to terminate a process (using the watchdog)
- Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
- Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Resolved: (EXEC-42) Tutorial should include example for asynchronous handling

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

Siegfried Goeschl resolved EXEC-42.
-----------------------------------

    Resolution: Fixed

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Commented: (EXEC-42) Tutorial should include example for asynchronous handling

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850489#action_12850489 ] 

Siegfried Goeschl commented on EXEC-42:
---------------------------------------

Always a good idea to improve the documentation - do you have a draft to start with?

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Reopened: (EXEC-42) Tutorial should include example for asynchronous handling

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

Siegfried Goeschl reopened EXEC-42:
-----------------------------------


Thanks - an additional pair of eyes is really helpful ... ;-)

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Commented: (EXEC-42) Tutorial should include example for asynchronous handling

Posted by "Maya Belcheva (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887784#action_12887784 ] 

Maya Belcheva commented on EXEC-42:
-----------------------------------

Hello. 
I have two questions:
1. Where I can find this updated version of the titorial? 
The only one that I found was http://commons.apache.org/exec/tutorial.html , but this one doesn't contain the comments included here and furthermore - the code available to download with this titorial was for another version (http://commons.apache.org/exec/download_exec.cgi) so the DefaultExecuteResultHandler class wasn't found.

2. I'm interested how one can read the OutputStream and the ErrorStream from the executed programme so is it possible to include such example in the titorial if it's not already done?

Thank you in advance.

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Updated: (EXEC-42) Tutorial should include example for asynchronous handling

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

Siegfried Goeschl updated EXEC-42:
----------------------------------

        Fix Version/s: 1.1
    Affects Version/s: 1.0.1
                       1.0

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Commented: (EXEC-42) Tutorial should include example for asynchronous handling

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887803#action_12887803 ] 

Siegfried Goeschl commented on EXEC-42:
---------------------------------------

Hi Maya,

the issues belong to non-released code yet - so I recommend getting the current source from SVN. In the JUnit regression test "DefaultExecutorTest" you find a lot of tests exercising the features you are interested in. AFAIK there is no test for capturing stderr yet. 

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Commented: (EXEC-42) Tutorial should include example for asynchronous handling

Posted by "Konrad Windszus (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875757#action_12875757 ] 

Konrad Windszus commented on EXEC-42:
-------------------------------------

Thanks for the update, some suggestions:

1. Fix the javadoc in the DefaultExecuteResultHandler.hasResult. The return value is true, if the process was finished, not the other way round.
2. Add a link to the javadoc of java.lang.Process which explains, why writes to stdout and stderr might be blocking, if you don't use the PumpStreamHandler, altough this is mentioned in the tutorial section, the link might be helpful for a more in depth information.
3. Add code for checking if process still running and also an example how to destroy the process if necessary
{code}
while (!resultHandler.hasResult()) {
	Thread.sleep(SLEEP_TIME_MS);
	if (interruptProcess) {
		watchdog.destroyProcess();
	}
}
exitCode = resultHandler.getExitValue();
{code}
SLEEP_TIME_MS is a constant which specifies the wait interval in milliseconds between the checks. In this example interruptProcess is a boolean variable, which might be set to interrupt the process. It would be helpful if you could add these lines in the tutorial example.
4. Add a hint in javadoc of Executor.execute that an exception is also thrown when the process has an invalid exit code (which is not allowed via Executor.setExitValue(s)).
5. Add a hint in javadoc in the ExecuteWatchdog, that it might be attached to the process after the DefaultExecutor.execute has returned. Also add that hint to all asynchronous Executor.execute methods.

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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


[jira] Resolved: (EXEC-42) Tutorial should include example for asynchronous handling

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

Siegfried Goeschl resolved EXEC-42.
-----------------------------------

    Resolution: Fixed

Updated the tutorial with patch from Pablo Hoertner - Konrad, can you have a look at it?!

> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

-- 
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: (EXEC-42) Tutorial should include example for asynchronous handling

Posted by "Konrad Windszus (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EXEC-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875757#action_12875757 ] 

Konrad Windszus edited comment on EXEC-42 at 6/4/10 5:19 PM:
-------------------------------------------------------------

Thanks for the update, some suggestions:

1. Fix the javadoc in the DefaultExecuteResultHandler.hasResult. The return value is true, if the process was finished, not the other way round.
2. Add a link to the javadoc of java.lang.Process (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Process.html) which explains, why writes to stdout and stderr might be blocking, if you don't use the PumpStreamHandler, altough this is mentioned in the tutorial section, the link might be helpful for a more in depth information.
3. Add code for checking if process still running and also an example how to destroy the process if necessary
{code}
while (!resultHandler.hasResult()) {
	Thread.sleep(SLEEP_TIME_MS);
	if (interruptProcess) {
		watchdog.destroyProcess();
	}
}
exitCode = resultHandler.getExitValue();
{code}
SLEEP_TIME_MS is a constant which specifies the wait interval in milliseconds between the checks. In this example interruptProcess is a boolean variable, which might be set to interrupt the process. It would be helpful if you could add these lines in the tutorial example.
4. Add a hint in javadoc of Executor.execute that an exception is also thrown when the process has an invalid exit code (which is not allowed via Executor.setExitValue(s)).
5. Add a hint in javadoc in the ExecuteWatchdog, that it might be attached to the process after the DefaultExecutor.execute has returned. Also add that hint to all asynchronous Executor.execute methods.

      was (Author: kwin):
    Thanks for the update, some suggestions:

1. Fix the javadoc in the DefaultExecuteResultHandler.hasResult. The return value is true, if the process was finished, not the other way round.
2. Add a link to the javadoc of java.lang.Process which explains, why writes to stdout and stderr might be blocking, if you don't use the PumpStreamHandler, altough this is mentioned in the tutorial section, the link might be helpful for a more in depth information.
3. Add code for checking if process still running and also an example how to destroy the process if necessary
{code}
while (!resultHandler.hasResult()) {
	Thread.sleep(SLEEP_TIME_MS);
	if (interruptProcess) {
		watchdog.destroyProcess();
	}
}
exitCode = resultHandler.getExitValue();
{code}
SLEEP_TIME_MS is a constant which specifies the wait interval in milliseconds between the checks. In this example interruptProcess is a boolean variable, which might be set to interrupt the process. It would be helpful if you could add these lines in the tutorial example.
4. Add a hint in javadoc of Executor.execute that an exception is also thrown when the process has an invalid exit code (which is not allowed via Executor.setExitValue(s)).
5. Add a hint in javadoc in the ExecuteWatchdog, that it might be attached to the process after the DefaultExecutor.execute has returned. Also add that hint to all asynchronous Executor.execute methods.
  
> Tutorial should include example for asynchronous handling
> ---------------------------------------------------------
>
>                 Key: EXEC-42
>                 URL: https://issues.apache.org/jira/browse/EXEC-42
>             Project: Commons Exec
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.0.1
>            Reporter: Konrad Windszus
>            Assignee: Siegfried Goeschl
>             Fix For: 1.1
>
>
> I had some difficulties figuring out, how to asynchronously start a process. You should include an example for this on the tutorial page. Especially interesting is the following:
> - How to start it (explain ExecuteResultHandler and that the callbacks are called from another thread, so these should be implemented thread-safe)
> - How to know if it is still running (not possible via watchdog, but has to be implemented for oneself using the ExecuteResultHandler, again watch out for thread safety)
> - How to force to terminate a process (using the watchdog)
> - Add a hint about StreamHandler and that you should always use a PumpStreamHandler (otherwise this could lead to deadlocks, see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?).
> - Add an explanation of exit values, since an exit value which is not in the list of the DefaultExecutor, leads automatically to an exception, which is not clear from the javadocs.

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