Uploaded image for project: 'Commons Exec'
  1. Commons Exec
  2. EXEC-71

Changes for EXEC-34 (Race condition prevent watchdog working using ExecuteStreamHandler) hang endlessly if the command cannot be found

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2
    • 1.4.0
    • Important

    Description

      The following test hangs endlessly for me because the ExecuteWatchdog will never get "processStarted = true" because starting an non-existing process will never lead to the started flag.

      @Test
      	public void testCommonsExecHang() throws Exception {
              CommandLine command = new CommandLine("someunexistingcommand");
              DefaultExecutor executor = new DefaultExecutor();
      
              ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
              executor.setWatchdog(watchdog);
      
              DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler() {
      			@Override
      			public void onProcessFailed(ExecuteException e) {
      		        System.out.println("Process did not stop gracefully, had exception '" + e.getMessage() + "' while executing process");
      				super.onProcessFailed(e);
      			}
              };
      
              executor.execute(command, null, resultHandler);
      
              // this hangs!!
              watchdog.isWatching();
      
              watchdog.destroyProcess();
      	}
      

      not calling isWatching(), but only destroyProcess() hangs as well!

      Options that I see: timeout the loop or handle the case of failure to start the Watchdog in DefaultExecutor.executeInternal() so that the Watchdog does not hang in this case

      Attachments

        Issue Links

          Activity

            People

              sgoeschl Siegfried Goeschl
              dominik.stadler@gmx.at Dominik Stadler
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: