{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments/77802155","id":77802155,"diff_hunk":"@@ -0,0 +1,152 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.wso2.carbon.container.runner;\n+/*\n+ *  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ *  Licensed under the Apache License, Version 2.0 (the \"License\");\n+ *  you may not use this file except in compliance with the License.\n+ *  You may obtain a copy of the License at\n+ *\n+ *  http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *  Unless required by applicable law or agreed to in writing, software\n+ *  distributed under the License is distributed on an \"AS IS\" BASIS,\n+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ *  See the License for the specific language governing permissions and\n+ *  limitations under the License.\n+ */\n+\n+import org.ops4j.io.Pipe;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+/**\n+ * Internal runner to create the framework process to start the distribution.\n+ */\n+public class InternalRunner {\n+\n+    private final Object shutdownHookMonitor = new Object();\n+    private final Object frameworkProcessMonitor = new Object();\n+    private Process frameworkProcess;\n+    private Thread shutdownHook;\n+\n+    /**\n+     * Execute the command and create a process for that.\n+     * @param commandLine command to be executed\n+     * @param envOptions environment options\n+     */\n+    public synchronized void exec(CommandLineBuilder commandLine, final String[] envOptions) {\n+        if (frameworkProcess != null) {\n+            throw new IllegalStateException(\"Server is already started\");\n+        }\n+\n+        try {\n+            frameworkProcess = Runtime.getRuntime()\n+                    .exec(commandLine.toArray(), createEnvironmentVars(envOptions), null);\n+        } catch (IOException e) {\n+            throw new IllegalStateException(\"Could not start up the process\", e);\n+        }\n+\n+        shutdownHook = createShutdownHook(frameworkProcess);\n+        Runtime.getRuntime().addShutdownHook(shutdownHook);\n+\n+        waitForExit();\n+    }\n+\n+    private String[] createEnvironmentVars(String[] envOptions) {\n+        List<String> env = new ArrayList<>();\n+        Map<String, String> getenv = System.getenv();\n+        env.addAll(getenv.keySet().stream().map(key -> key + \"=\" + getenv.get(key)).collect(Collectors.toList()));\n+        if (envOptions != null) {\n+            Collections.addAll(env, envOptions);\n+        }\n+        return env.toArray(new String[env.size()]);\n+    }\n+\n+    /**\n+     * Properly destroy the process.\n+     */\n+    public synchronized void shutdown() {\n+        try {\n+            if (shutdownHook != null) {\n+                synchronized (shutdownHookMonitor) {\n+                    if (shutdownHook != null) {\n+                        Runtime.getRuntime().removeShutdownHook(shutdownHook);\n+                        frameworkProcess = null;\n+                        shutdownHook.start();\n+                        shutdownHook = null;\n+                    }\n+                }\n+            }\n+        } catch (IllegalStateException ignore) {\n+","path":"pax-exam-container-carbon/org.wso2.carbon.container/src/main/java/org/wso2/carbon/container/runner/InternalRunner.java","position":102,"original_position":102,"commit_id":"498d1b52bdad374babe700969226ef84658e24c1","original_commit_id":"498d1b52bdad374babe700969226ef84658e24c1","user":{"login":"jsdjayanga","id":5029961,"avatar_url":"https://avatars.githubusercontent.com/u/5029961?v=3","gravatar_id":"","url":"https://api.github.com/users/jsdjayanga","html_url":"https://github.com/jsdjayanga","followers_url":"https://api.github.com/users/jsdjayanga/followers","following_url":"https://api.github.com/users/jsdjayanga/following{/other_user}","gists_url":"https://api.github.com/users/jsdjayanga/gists{/gist_id}","starred_url":"https://api.github.com/users/jsdjayanga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsdjayanga/subscriptions","organizations_url":"https://api.github.com/users/jsdjayanga/orgs","repos_url":"https://api.github.com/users/jsdjayanga/repos","events_url":"https://api.github.com/users/jsdjayanga/events{/privacy}","received_events_url":"https://api.github.com/users/jsdjayanga/received_events","type":"User","site_admin":false},"body":"Log the Exception","created_at":"2016-09-07T11:10:42Z","updated_at":"2016-09-07T11:10:42Z","html_url":"https://github.com/wso2/carbon-kernel/pull/1110#discussion_r77802155","pull_request_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments/77802155"},"html":{"href":"https://github.com/wso2/carbon-kernel/pull/1110#discussion_r77802155"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110","id":81836324,"html_url":"https://github.com/wso2/carbon-kernel/pull/1110","diff_url":"https://github.com/wso2/carbon-kernel/pull/1110.diff","patch_url":"https://github.com/wso2/carbon-kernel/pull/1110.patch","issue_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/1110","number":1110,"state":"open","locked":false,"title":"Pax Exam Container for C5","user":{"login":"ChanakaCooray","id":4003117,"avatar_url":"https://avatars.githubusercontent.com/u/4003117?v=3","gravatar_id":"","url":"https://api.github.com/users/ChanakaCooray","html_url":"https://github.com/ChanakaCooray","followers_url":"https://api.github.com/users/ChanakaCooray/followers","following_url":"https://api.github.com/users/ChanakaCooray/following{/other_user}","gists_url":"https://api.github.com/users/ChanakaCooray/gists{/gist_id}","starred_url":"https://api.github.com/users/ChanakaCooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChanakaCooray/subscriptions","organizations_url":"https://api.github.com/users/ChanakaCooray/orgs","repos_url":"https://api.github.com/users/ChanakaCooray/repos","events_url":"https://api.github.com/users/ChanakaCooray/events{/privacy}","received_events_url":"https://api.github.com/users/ChanakaCooray/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-18T15:28:31Z","updated_at":"2016-09-07T11:10:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c4a64c500214fb035685fa09b8bc5cd9e6c74be4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/1110/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-kernel/statuses/498d1b52bdad374babe700969226ef84658e24c1","head":{"label":"ChanakaCooray:paxexamcontainer","ref":"paxexamcontainer","sha":"498d1b52bdad374babe700969226ef84658e24c1","user":{"login":"ChanakaCooray","id":4003117,"avatar_url":"https://avatars.githubusercontent.com/u/4003117?v=3","gravatar_id":"","url":"https://api.github.com/users/ChanakaCooray","html_url":"https://github.com/ChanakaCooray","followers_url":"https://api.github.com/users/ChanakaCooray/followers","following_url":"https://api.github.com/users/ChanakaCooray/following{/other_user}","gists_url":"https://api.github.com/users/ChanakaCooray/gists{/gist_id}","starred_url":"https://api.github.com/users/ChanakaCooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChanakaCooray/subscriptions","organizations_url":"https://api.github.com/users/ChanakaCooray/orgs","repos_url":"https://api.github.com/users/ChanakaCooray/repos","events_url":"https://api.github.com/users/ChanakaCooray/events{/privacy}","received_events_url":"https://api.github.com/users/ChanakaCooray/received_events","type":"User","site_admin":false},"repo":{"id":55607731,"name":"carbon-kernel","full_name":"ChanakaCooray/carbon-kernel","owner":{"login":"ChanakaCooray","id":4003117,"avatar_url":"https://avatars.githubusercontent.com/u/4003117?v=3","gravatar_id":"","url":"https://api.github.com/users/ChanakaCooray","html_url":"https://github.com/ChanakaCooray","followers_url":"https://api.github.com/users/ChanakaCooray/followers","following_url":"https://api.github.com/users/ChanakaCooray/following{/other_user}","gists_url":"https://api.github.com/users/ChanakaCooray/gists{/gist_id}","starred_url":"https://api.github.com/users/ChanakaCooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChanakaCooray/subscriptions","organizations_url":"https://api.github.com/users/ChanakaCooray/orgs","repos_url":"https://api.github.com/users/ChanakaCooray/repos","events_url":"https://api.github.com/users/ChanakaCooray/events{/privacy}","received_events_url":"https://api.github.com/users/ChanakaCooray/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ChanakaCooray/carbon-kernel","description":"","fork":true,"url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel","forks_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/forks","keys_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/teams","hooks_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/hooks","issue_events_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/events","assignees_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/tags","blobs_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/languages","stargazers_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/stargazers","contributors_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/contributors","subscribers_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/subscribers","subscription_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/subscription","commits_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/merges","archive_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/downloads","issues_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/ChanakaCooray/carbon-kernel/deployments","created_at":"2016-04-06T13:20:59Z","updated_at":"2016-04-06T13:21:01Z","pushed_at":"2016-09-07T08:50:32Z","git_url":"git://github.com/ChanakaCooray/carbon-kernel.git","ssh_url":"git@github.com:ChanakaCooray/carbon-kernel.git","clone_url":"https://github.com/ChanakaCooray/carbon-kernel.git","svn_url":"https://github.com/ChanakaCooray/carbon-kernel","homepage":null,"size":42850,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"d1b66b0512d00926b62c45059cae5f3c912d23b2","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":16162184,"name":"carbon-kernel","full_name":"wso2/carbon-kernel","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-kernel","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-kernel","forks_url":"https://api.github.com/repos/wso2/carbon-kernel/forks","keys_url":"https://api.github.com/repos/wso2/carbon-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-kernel/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-kernel/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-kernel/events","assignees_url":"https://api.github.com/repos/wso2/carbon-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-kernel/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-kernel/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-kernel/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-kernel/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-kernel/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-kernel/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-kernel/merges","archive_url":"https://api.github.com/repos/wso2/carbon-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-kernel/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-kernel/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/carbon-kernel/deployments","created_at":"2014-01-23T04:23:41Z","updated_at":"2016-05-19T05:03:01Z","pushed_at":"2016-09-07T09:28:25Z","git_url":"git://github.com/wso2/carbon-kernel.git","ssh_url":"git@github.com:wso2/carbon-kernel.git","clone_url":"https://github.com/wso2/carbon-kernel.git","svn_url":"https://github.com/wso2/carbon-kernel","homepage":null,"size":48765,"stargazers_count":34,"watchers_count":34,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":257,"mirror_url":null,"open_issues_count":30,"forks":257,"open_issues":30,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110"},"html":{"href":"https://github.com/wso2/carbon-kernel/pull/1110"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-kernel/issues/1110"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-kernel/issues/1110/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-kernel/pulls/1110/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-kernel/statuses/498d1b52bdad374babe700969226ef84658e24c1"}}}}
{"actor":{"display_login":"jsdjayanga"}}