{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/224177081","pull_request_review_id":163481203,"id":224177081,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDE3NzA4MQ==","diff_hunk":"@@ -101,39 +104,58 @@ public void bindBundleContext() {\n     }\n \n     /**\n-     * Get an OSGi service for the given class and the given filter.\n+     * Get all OSGi service for the given class and the given filter.\n      *\n      * @param clazz class under which the OSGi service is registered\n-     * @param filter\n-     * @return OSGi service or null if no service can be found for the given class\n+     * @param filter Predicate to apply to found ServiceReferences\n+     * @return List of OSGi services or empty List if no service can be found for the given class and filter\n      */\n-    protected <T> @Nullable T getService(Class<T> clazz, Predicate<ServiceReference<T>> filter) {\n-        final ServiceReference<T> serviceReferences[] = getServices(clazz);\n+    protected <T> List<T> getServices(Class<T> clazz, Predicate<ServiceReference<T>> filter) {\n+        final ServiceReference<@Nullable T> serviceReferences[] = getServices(clazz);\n \n         if (serviceReferences == null) {\n             new MissingServiceAnalyzer(System.out, bundleContext).printMissingServiceDetails(clazz);\n-            return null;\n-        }\n-        final List<T> filteredServiceReferences = new ArrayList<>(serviceReferences.length);\n-        for (final ServiceReference<T> serviceReference : serviceReferences) {\n-            if (filter.test(serviceReference)) {\n-                filteredServiceReferences.add(unrefService(serviceReference));\n-            }\n+            return Collections.emptyList();\n         }\n \n-        if (filteredServiceReferences.size() > 1) {\n+        return Arrays //\n+                .stream(serviceReferences) //\n+                .filter(filter) // apply the predicate\n+                .map(this::unrefService) // get the actual services from the references\n+                .collect(Collectors.toList()); // get the result as List\n+    }\n+\n+    /**\n+     * Get an OSGi service for the given class and the given filter.\n+     *\n+     * @param clazz class under which the OSGi service is registered\n+     * @param filter Predicate to apply to found ServiceReferences\n+     * @return OSGi service or null if no service can be found for the given class\n+     * @throws AssertionError if more than one instance of the service is found\n+     */\n+    protected <T> @Nullable T getService(Class<T> clazz, Predicate<ServiceReference<T>> filter) {\n+        final List<T> filteredServices = getServices(clazz, filter);\n+\n+        return getSingleServiceInstance(clazz, filteredServices);\n+    }\n+\n+    /**\n+     * Get the single instance of an OSGi service or throw an {@link AssertionError} if multiple instances were found.\n+     *\n+     * @param clazz under which the OSGi service is registered\n+     * @param filteredServices List of found services\n+     * @return OSGi service or null if no service was found for the given class\n+     * @throws AssertionError if more than one instance of the service is found\n+     */\n+    private <I, T extends I> @Nullable I getSingleServiceInstance(Class<T> clazz, final List<I> filteredServices) {","path":"bundles/test/org.eclipse.smarthome.test/src/main/java/org/eclipse/smarthome/test/java/JavaOSGiTest.java","position":null,"original_position":75,"commit_id":"fca16d0047a126b8d04c744aa2e8412a38101626","original_commit_id":"74552f9f2b2cd3ecb20c238d385f4fc80f25bf22","user":{"login":"ViToni","id":10586564,"node_id":"MDQ6VXNlcjEwNTg2NTY0","avatar_url":"https://avatars2.githubusercontent.com/u/10586564?v=4","gravatar_id":"","url":"https://api.github.com/users/ViToni","html_url":"https://github.com/ViToni","followers_url":"https://api.github.com/users/ViToni/followers","following_url":"https://api.github.com/users/ViToni/following{/other_user}","gists_url":"https://api.github.com/users/ViToni/gists{/gist_id}","starred_url":"https://api.github.com/users/ViToni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViToni/subscriptions","organizations_url":"https://api.github.com/users/ViToni/orgs","repos_url":"https://api.github.com/users/ViToni/repos","events_url":"https://api.github.com/users/ViToni/events{/privacy}","received_events_url":"https://api.github.com/users/ViToni/received_events","type":"User","site_admin":false},"body":"Fixed.","created_at":"2018-10-10T17:46:26Z","updated_at":"2018-10-10T17:46:27Z","html_url":"https://github.com/eclipse/smarthome/pull/6343#discussion_r224177081","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/6343","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/224177081"},"html":{"href":"https://github.com/eclipse/smarthome/pull/6343#discussion_r224177081"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/6343"}},"in_reply_to_id":224161182},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/6343","id":221821006,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxODIxMDA2","html_url":"https://github.com/eclipse/smarthome/pull/6343","diff_url":"https://github.com/eclipse/smarthome/pull/6343.diff","patch_url":"https://github.com/eclipse/smarthome/pull/6343.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/6343","number":6343,"state":"open","locked":false,"title":"Added methods to JavaOSGiTest to retrieve multiple instances of a service.","user":{"login":"ViToni","id":10586564,"node_id":"MDQ6VXNlcjEwNTg2NTY0","avatar_url":"https://avatars2.githubusercontent.com/u/10586564?v=4","gravatar_id":"","url":"https://api.github.com/users/ViToni","html_url":"https://github.com/ViToni","followers_url":"https://api.github.com/users/ViToni/followers","following_url":"https://api.github.com/users/ViToni/following{/other_user}","gists_url":"https://api.github.com/users/ViToni/gists{/gist_id}","starred_url":"https://api.github.com/users/ViToni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViToni/subscriptions","organizations_url":"https://api.github.com/users/ViToni/orgs","repos_url":"https://api.github.com/users/ViToni/repos","events_url":"https://api.github.com/users/ViToni/events{/privacy}","received_events_url":"https://api.github.com/users/ViToni/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Victor Toni <victor.toni@gmail.com>","created_at":"2018-10-10T14:52:20Z","updated_at":"2018-10-10T17:46:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"800b12f550adb68884ab586ec69c72baa482dc5b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":490881643,"node_id":"MDU6TGFiZWw0OTA4ODE2NDM=","url":"https://api.github.com/repos/eclipse/smarthome/labels/APIBreaking","name":"APIBreaking","color":"5319e7","default":false},{"id":427960976,"node_id":"MDU6TGFiZWw0Mjc5NjA5NzY=","url":"https://api.github.com/repos/eclipse/smarthome/labels/Test","name":"Test","color":"d4c5f9","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/6343/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/6343/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/6343/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/fca16d0047a126b8d04c744aa2e8412a38101626","head":{"label":"ViToni:feature/enable_retrieval_of_multiple_services","ref":"feature/enable_retrieval_of_multiple_services","sha":"fca16d0047a126b8d04c744aa2e8412a38101626","user":{"login":"ViToni","id":10586564,"node_id":"MDQ6VXNlcjEwNTg2NTY0","avatar_url":"https://avatars2.githubusercontent.com/u/10586564?v=4","gravatar_id":"","url":"https://api.github.com/users/ViToni","html_url":"https://github.com/ViToni","followers_url":"https://api.github.com/users/ViToni/followers","following_url":"https://api.github.com/users/ViToni/following{/other_user}","gists_url":"https://api.github.com/users/ViToni/gists{/gist_id}","starred_url":"https://api.github.com/users/ViToni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViToni/subscriptions","organizations_url":"https://api.github.com/users/ViToni/orgs","repos_url":"https://api.github.com/users/ViToni/repos","events_url":"https://api.github.com/users/ViToni/events{/privacy}","received_events_url":"https://api.github.com/users/ViToni/received_events","type":"User","site_admin":false},"repo":{"id":80031973,"node_id":"MDEwOlJlcG9zaXRvcnk4MDAzMTk3Mw==","name":"smarthome","full_name":"ViToni/smarthome","private":false,"owner":{"login":"ViToni","id":10586564,"node_id":"MDQ6VXNlcjEwNTg2NTY0","avatar_url":"https://avatars2.githubusercontent.com/u/10586564?v=4","gravatar_id":"","url":"https://api.github.com/users/ViToni","html_url":"https://github.com/ViToni","followers_url":"https://api.github.com/users/ViToni/followers","following_url":"https://api.github.com/users/ViToni/following{/other_user}","gists_url":"https://api.github.com/users/ViToni/gists{/gist_id}","starred_url":"https://api.github.com/users/ViToni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViToni/subscriptions","organizations_url":"https://api.github.com/users/ViToni/orgs","repos_url":"https://api.github.com/users/ViToni/repos","events_url":"https://api.github.com/users/ViToni/events{/privacy}","received_events_url":"https://api.github.com/users/ViToni/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ViToni/smarthome","description":"Eclipse SmartHome™ project","fork":true,"url":"https://api.github.com/repos/ViToni/smarthome","forks_url":"https://api.github.com/repos/ViToni/smarthome/forks","keys_url":"https://api.github.com/repos/ViToni/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ViToni/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ViToni/smarthome/teams","hooks_url":"https://api.github.com/repos/ViToni/smarthome/hooks","issue_events_url":"https://api.github.com/repos/ViToni/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/ViToni/smarthome/events","assignees_url":"https://api.github.com/repos/ViToni/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/ViToni/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/ViToni/smarthome/tags","blobs_url":"https://api.github.com/repos/ViToni/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ViToni/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ViToni/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/ViToni/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ViToni/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/ViToni/smarthome/languages","stargazers_url":"https://api.github.com/repos/ViToni/smarthome/stargazers","contributors_url":"https://api.github.com/repos/ViToni/smarthome/contributors","subscribers_url":"https://api.github.com/repos/ViToni/smarthome/subscribers","subscription_url":"https://api.github.com/repos/ViToni/smarthome/subscription","commits_url":"https://api.github.com/repos/ViToni/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/ViToni/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/ViToni/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/ViToni/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/ViToni/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/ViToni/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ViToni/smarthome/merges","archive_url":"https://api.github.com/repos/ViToni/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ViToni/smarthome/downloads","issues_url":"https://api.github.com/repos/ViToni/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/ViToni/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/ViToni/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/ViToni/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ViToni/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/ViToni/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/ViToni/smarthome/deployments","created_at":"2017-01-25T16:18:57Z","updated_at":"2017-01-25T16:19:07Z","pushed_at":"2018-10-10T17:45:44Z","git_url":"git://github.com/ViToni/smarthome.git","ssh_url":"git@github.com:ViToni/smarthome.git","clone_url":"https://github.com/ViToni/smarthome.git","svn_url":"https://github.com/ViToni/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":48698,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0","node_id":"MDc6TGljZW5zZTc="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"2b99b7b799518f42316a212eefe38211d6cc7e9a","user":{"login":"eclipse","id":56974,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2OTc0","avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc3ODk4MQ==","name":"smarthome","full_name":"eclipse/smarthome","private":false,"owner":{"login":"eclipse","id":56974,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2OTc0","avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome™ project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/smarthome/deployments","created_at":"2014-01-09T20:47:19Z","updated_at":"2018-10-10T16:35:32Z","pushed_at":"2018-10-10T17:45:45Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":61779,"stargazers_count":755,"watchers_count":755,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":749,"mirror_url":null,"archived":false,"open_issues_count":438,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0","node_id":"MDc6TGljZW5zZTMy"},"forks":749,"open_issues":438,"watchers":755,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/6343"},"html":{"href":"https://github.com/eclipse/smarthome/pull/6343"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/6343"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/6343/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/6343/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/6343/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/fca16d0047a126b8d04c744aa2e8412a38101626"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ViToni"}}