GitHub PullRequestReviewCommentEvent at 2014-05-28 12:43:16
Repository: fitnesse-plugin
Actor: antoine-aumjaud
Payload: {"comment":{"url":"https://api.github.com/repos/jenkinsci/fitnesse-plugin/pulls/comments/13128643","id":13128643,"diff_hunk":"@@ -137,58 +138,61 @@ private Proc startFitnesse(AbstractBuild<?,?> build, Launcher launcher, EnvVars\n \t\tString[] ret = new String[addOps.size()];\n \t\treturn addOps.toArray(ret);\n \t}\n-    \n-\tprivate boolean procStarted(Proc fitnesseProc, PrintStream log, StdConsole console) throws IOException, InterruptedException {\n-\t\tif (fitnesseProc.isAlive()) {\n-\t\t\treturn fitnesseStarted(log, console, STARTUP_TIMEOUT_MILLIS);\n-\t\t}\n-\t\treturn false;\n-\t}\n-\t\n+\n \t/**\n-\t * Detect if fitnesse has started by monitoring the console.\n-\t * If fitnesse.jar is unpacking itself there will be an initial write\n-\t * to stderr followed by multiple writes to stdout, otherwise there \n-\t * should only be an initial short write to stdout (and any writes to stderr\n-\t * are probably exception messages.) \n+\t * Detect if fitnesse has started by try to do an HTTP connection\n+\t * \n \t * @return true if fitnesse has started, false otherwise\n \t */\n-\tpublic boolean fitnesseStarted(PrintStream log, StdConsole console, long timeout) throws InterruptedException {\n-\t\tlong waitedAlready = 0;\n-\t\tdo {\n-\t\t\tThread.sleep(SLEEP_MILLIS);\n-\t\t\tif (console.noIncrementalOutput()) {\n-\t\t\t\twaitedAlready += SLEEP_MILLIS;\n-\t\t\t} else {\n-\t\t\t\tif (console.incrementalOutputOnStdErr()) \n-\t\t\t\t\ttimeout += ADDITIONAL_TIMEOUT_MILLIS;\n-\t\t\t\tconsole.logIncrementalOutput(log);\n+\tpublic boolean isFitnesseStarted(URL fitnessePageURL) throws InterruptedException {\n+\t\tlong waitedAlready;\n+\t\tboolean launched = false;\n+\t\tlogger.print(\"Wait for Fitnesse Server start\");\n+\t\tfor (waitedAlready = 0; waitedAlready < STARTUP_TIMEOUT_MILLIS; waitedAlready += SLEEP_MILLIS) {\n+\t\t\tHttpURLConnection connection = null;\n+\t\t\ttry {\n+\t\t\t\tconnection = (HttpURLConnection) fitnessePageURL.openConnection();\n+\t\t\t\tconnection.setRequestMethod(\"GET\"); //HEAD is not allowed on Fitnesse server (error 400)\n+\t\t\t\tconnection.setReadTimeout(READ_PAGE_TIMEOUT);\n+\t\t\t\tint responseCode = connection.getResponseCode();\n+\t\t\t\tif (responseCode != 200)\n+\t\t\t\t\tthrow new RuntimeException(String.format(\"Response for page %s is %d\", fitnessePageURL,\n+\t\t\t\t\t    responseCode));\n+\t\t\t\tlaunched = true;\n+\t\t\t\tbreak;\n+\t\t\t} catch (IOException e) {\n+\t\t\t\tlogger.print('.');","path":"src/main/java/hudson/plugins/fitnesse/FitnesseExecutor.java","position":150,"original_position":150,"commit_id":"6432018fb6e13d6414c21b36bebcb0dd5da0c579","original_commit_id":"6432018fb6e13d6414c21b36bebcb0dd5da0c579","user":{"login":"antoine-aumjaud","id":1887404,"avatar_url":"https://avatars.githubusercontent.com/u/1887404?","gravatar_id":"a5891946ba8b9298b8250dccb86c2a45","url":"https://api.github.com/users/antoine-aumjaud","html_url":"https://github.com/antoine-aumjaud","followers_url":"https://api.github.com/users/antoine-aumjaud/followers","following_url":"https://api.github.com/users/antoine-aumjaud/following{/other_user}","gists_url":"https://api.github.com/users/antoine-aumjaud/gists{/gist_id}","starred_url":"https://api.github.com/users/antoine-aumjaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoine-aumjaud/subscriptions","organizations_url":"https://api.github.com/users/antoine-aumjaud/orgs","repos_url":"https://api.github.com/users/antoine-aumjaud/repos","events_url":"https://api.github.com/users/antoine-aumjaud/events{/privacy}","received_events_url":"https://api.github.com/users/antoine-aumjaud/received_events","type":"User","site_admin":false},"body":"In fact the plugin logged only if there was no output on stdout. \r\nThis case occurs when fitnesse unzip new files from the JAR (before the JUL migration, Fitnesse writes this information on stderr)\r\n\r\nI think that the time (<30s) waited is not necessary, I 've just add a dot. \r\nBut tell me, I can add the elapsed time.","created_at":"2014-05-28T12:43:16Z","updated_at":"2014-05-28T12:43:16Z","html_url":"https://github.com/jenkinsci/fitnesse-plugin/pull/13#discussion_r13128643","pull_request_url":"https://api.github.com/repos/jenkinsci/fitnesse-plugin/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/fitnesse-plugin/pulls/comments/13128643"},"html":{"href":"https://github.com/jenkinsci/fitnesse-plugin/pull/13#discussion_r13128643"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/fitnesse-plugin/pulls/13"}}}}