{"action":"created","comment":{"url":"https://api.github.com/repos/apache/kafka/pulls/comments/67919003","id":67919003,"diff_hunk":"@@ -67,22 +67,32 @@ class NewShinyConsumer(topic: Option[String], partitionId: Option[Int], offset:\n   var recordIter = consumer.poll(0).iterator\n \n   def consumerInit() {\n-    if (topic.isDefined)\n-      if (partitionId.isDefined) {\n-        val topicPartition = new TopicPartition(topic.get, partitionId.get)\n-        consumer.assign(List(topicPartition))\n-        offset.get match {\n-          case OffsetRequest.EarliestTime => consumer.seekToBeginning(List(topicPartition))\n-          case OffsetRequest.LatestTime => consumer.seekToEnd(List(topicPartition))\n-          case _ => consumer.seek(topicPartition, offset.get)\n-        }\n-      }\n-      else\n-        consumer.subscribe(List(topic.get))\n-    else if (whitelist.isDefined)\n-      consumer.subscribe(Pattern.compile(whitelist.get), new NoOpConsumerRebalanceListener())\n-    else\n-      throw new IllegalArgumentException(\"Exactly one of topic or whitelist has to be provided.\")\n+    (topic, partitionId, offset, whitelist) match {\n+      case (Some(topic), Some(partitionId), Some(offset), None) =>\n+        seek(topic, partitionId, offset)\n+      case (Some(topic), Some(partitionId), None, None) =>\n+        // default to earliest if no offset is provided\n+        seek(topic, partitionId, OffsetRequest.EarliestTime)\n+      case (Some(topic), None, None, None) =>\n+        consumer.subscribe(List(topic))\n+      case (None, None, None, Some(whitelist)) =>\n+        consumer.subscribe(Pattern.compile(whitelist), new NoOpConsumerRebalanceListener())\n+      case _ =>\n+        throw new IllegalArgumentException(\"An invalid combination of arguments is provided. \" +\n+            \"Exactly one of 'topic' or 'whitelist' must be provided. \" +\n+            \"If 'topic' is provided, an optional 'partition' may also be provided. \" +\n+            \"If 'partition' is provided, an optional 'offset' may also be provided, otherwise, consumption starts from the earliest message.\")\n+    }\n+  }","path":"core/src/main/scala/kafka/consumer/BaseConsumer.scala","position":36,"original_position":36,"commit_id":"843026de9c224235fe46f3fc0e882cfd4f4fbf15","original_commit_id":"843026de9c224235fe46f3fc0e882cfd4f4fbf15","user":{"login":"vahidhashemian","id":13593506,"avatar_url":"https://avatars.githubusercontent.com/u/13593506?v=3","gravatar_id":"","url":"https://api.github.com/users/vahidhashemian","html_url":"https://github.com/vahidhashemian","followers_url":"https://api.github.com/users/vahidhashemian/followers","following_url":"https://api.github.com/users/vahidhashemian/following{/other_user}","gists_url":"https://api.github.com/users/vahidhashemian/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidhashemian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidhashemian/subscriptions","organizations_url":"https://api.github.com/users/vahidhashemian/orgs","repos_url":"https://api.github.com/users/vahidhashemian/repos","events_url":"https://api.github.com/users/vahidhashemian/events{/privacy}","received_events_url":"https://api.github.com/users/vahidhashemian/received_events","type":"User","site_admin":false},"body":"@ijuma I added an additional `case` for when `topic` and `partition` are provided but offset is missing. I also updated the exception message to be more descriptive as you suggested. Please advise if you see an issue. Thanks.","created_at":"2016-06-21T17:56:58Z","updated_at":"2016-06-21T17:56:58Z","html_url":"https://github.com/apache/kafka/pull/1536#discussion_r67919003","pull_request_url":"https://api.github.com/repos/apache/kafka/pulls/1536","_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments/67919003"},"html":{"href":"https://github.com/apache/kafka/pull/1536#discussion_r67919003"},"pull_request":{"href":"https://api.github.com/repos/apache/kafka/pulls/1536"}}},"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/1536","id":74656802,"html_url":"https://github.com/apache/kafka/pull/1536","diff_url":"https://github.com/apache/kafka/pull/1536.diff","patch_url":"https://github.com/apache/kafka/pull/1536.patch","issue_url":"https://api.github.com/repos/apache/kafka/issues/1536","number":1536,"state":"open","locked":false,"title":"MINOR: KAFKA-3176 Follow-up to fix minor issues","user":{"login":"vahidhashemian","id":13593506,"avatar_url":"https://avatars.githubusercontent.com/u/13593506?v=3","gravatar_id":"","url":"https://api.github.com/users/vahidhashemian","html_url":"https://github.com/vahidhashemian","followers_url":"https://api.github.com/users/vahidhashemian/followers","following_url":"https://api.github.com/users/vahidhashemian/following{/other_user}","gists_url":"https://api.github.com/users/vahidhashemian/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidhashemian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidhashemian/subscriptions","organizations_url":"https://api.github.com/users/vahidhashemian/orgs","repos_url":"https://api.github.com/users/vahidhashemian/repos","events_url":"https://api.github.com/users/vahidhashemian/events{/privacy}","received_events_url":"https://api.github.com/users/vahidhashemian/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-21T17:53:40Z","updated_at":"2016-06-21T17:56:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6daa03602f34b696f5eb82e29fc46b1cff4b1bc4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/kafka/pulls/1536/commits","review_comments_url":"https://api.github.com/repos/apache/kafka/pulls/1536/comments","review_comment_url":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/kafka/issues/1536/comments","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/843026de9c224235fe46f3fc0e882cfd4f4fbf15","head":{"label":"vahidhashemian:minor/KAFKA-3176-Followup","ref":"minor/KAFKA-3176-Followup","sha":"843026de9c224235fe46f3fc0e882cfd4f4fbf15","user":{"login":"vahidhashemian","id":13593506,"avatar_url":"https://avatars.githubusercontent.com/u/13593506?v=3","gravatar_id":"","url":"https://api.github.com/users/vahidhashemian","html_url":"https://github.com/vahidhashemian","followers_url":"https://api.github.com/users/vahidhashemian/followers","following_url":"https://api.github.com/users/vahidhashemian/following{/other_user}","gists_url":"https://api.github.com/users/vahidhashemian/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidhashemian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidhashemian/subscriptions","organizations_url":"https://api.github.com/users/vahidhashemian/orgs","repos_url":"https://api.github.com/users/vahidhashemian/repos","events_url":"https://api.github.com/users/vahidhashemian/events{/privacy}","received_events_url":"https://api.github.com/users/vahidhashemian/received_events","type":"User","site_admin":false},"repo":{"id":47428717,"name":"kafka","full_name":"vahidhashemian/kafka","owner":{"login":"vahidhashemian","id":13593506,"avatar_url":"https://avatars.githubusercontent.com/u/13593506?v=3","gravatar_id":"","url":"https://api.github.com/users/vahidhashemian","html_url":"https://github.com/vahidhashemian","followers_url":"https://api.github.com/users/vahidhashemian/followers","following_url":"https://api.github.com/users/vahidhashemian/following{/other_user}","gists_url":"https://api.github.com/users/vahidhashemian/gists{/gist_id}","starred_url":"https://api.github.com/users/vahidhashemian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vahidhashemian/subscriptions","organizations_url":"https://api.github.com/users/vahidhashemian/orgs","repos_url":"https://api.github.com/users/vahidhashemian/repos","events_url":"https://api.github.com/users/vahidhashemian/events{/privacy}","received_events_url":"https://api.github.com/users/vahidhashemian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vahidhashemian/kafka","description":"Mirror of Apache Kafka","fork":true,"url":"https://api.github.com/repos/vahidhashemian/kafka","forks_url":"https://api.github.com/repos/vahidhashemian/kafka/forks","keys_url":"https://api.github.com/repos/vahidhashemian/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vahidhashemian/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vahidhashemian/kafka/teams","hooks_url":"https://api.github.com/repos/vahidhashemian/kafka/hooks","issue_events_url":"https://api.github.com/repos/vahidhashemian/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/vahidhashemian/kafka/events","assignees_url":"https://api.github.com/repos/vahidhashemian/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/vahidhashemian/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/vahidhashemian/kafka/tags","blobs_url":"https://api.github.com/repos/vahidhashemian/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vahidhashemian/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vahidhashemian/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/vahidhashemian/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vahidhashemian/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/vahidhashemian/kafka/languages","stargazers_url":"https://api.github.com/repos/vahidhashemian/kafka/stargazers","contributors_url":"https://api.github.com/repos/vahidhashemian/kafka/contributors","subscribers_url":"https://api.github.com/repos/vahidhashemian/kafka/subscribers","subscription_url":"https://api.github.com/repos/vahidhashemian/kafka/subscription","commits_url":"https://api.github.com/repos/vahidhashemian/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/vahidhashemian/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/vahidhashemian/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/vahidhashemian/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/vahidhashemian/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/vahidhashemian/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vahidhashemian/kafka/merges","archive_url":"https://api.github.com/repos/vahidhashemian/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vahidhashemian/kafka/downloads","issues_url":"https://api.github.com/repos/vahidhashemian/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/vahidhashemian/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/vahidhashemian/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/vahidhashemian/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vahidhashemian/kafka/labels{/name}","releases_url":"https://api.github.com/repos/vahidhashemian/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/vahidhashemian/kafka/deployments","created_at":"2015-12-04T21:04:22Z","updated_at":"2016-01-14T22:16:55Z","pushed_at":"2016-06-21T17:49:39Z","git_url":"git://github.com/vahidhashemian/kafka.git","ssh_url":"git@github.com:vahidhashemian/kafka.git","clone_url":"https://github.com/vahidhashemian/kafka.git","svn_url":"https://github.com/vahidhashemian/kafka","homepage":null,"size":32204,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"9716768810635b75b7668730962c399048ca883e","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":2211243,"name":"kafka","full_name":"apache/kafka","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/kafka","description":"Mirror of Apache Kafka","fork":false,"url":"https://api.github.com/repos/apache/kafka","forks_url":"https://api.github.com/repos/apache/kafka/forks","keys_url":"https://api.github.com/repos/apache/kafka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/kafka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/kafka/teams","hooks_url":"https://api.github.com/repos/apache/kafka/hooks","issue_events_url":"https://api.github.com/repos/apache/kafka/issues/events{/number}","events_url":"https://api.github.com/repos/apache/kafka/events","assignees_url":"https://api.github.com/repos/apache/kafka/assignees{/user}","branches_url":"https://api.github.com/repos/apache/kafka/branches{/branch}","tags_url":"https://api.github.com/repos/apache/kafka/tags","blobs_url":"https://api.github.com/repos/apache/kafka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/kafka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/kafka/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/kafka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/kafka/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/kafka/languages","stargazers_url":"https://api.github.com/repos/apache/kafka/stargazers","contributors_url":"https://api.github.com/repos/apache/kafka/contributors","subscribers_url":"https://api.github.com/repos/apache/kafka/subscribers","subscription_url":"https://api.github.com/repos/apache/kafka/subscription","commits_url":"https://api.github.com/repos/apache/kafka/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/kafka/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/kafka/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/kafka/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/kafka/contents/{+path}","compare_url":"https://api.github.com/repos/apache/kafka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/kafka/merges","archive_url":"https://api.github.com/repos/apache/kafka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/kafka/downloads","issues_url":"https://api.github.com/repos/apache/kafka/issues{/number}","pulls_url":"https://api.github.com/repos/apache/kafka/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/kafka/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/kafka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/kafka/labels{/name}","releases_url":"https://api.github.com/repos/apache/kafka/releases{/id}","deployments_url":"https://api.github.com/repos/apache/kafka/deployments","created_at":"2011-08-15T18:06:16Z","updated_at":"2016-06-21T16:44:12Z","pushed_at":"2016-06-21T17:53:40Z","git_url":"git://github.com/apache/kafka.git","ssh_url":"git@github.com:apache/kafka.git","clone_url":"https://github.com/apache/kafka.git","svn_url":"https://github.com/apache/kafka","homepage":null,"size":44184,"stargazers_count":3289,"watchers_count":3289,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2027,"mirror_url":"git://git.apache.org/kafka.git","open_issues_count":197,"forks":2027,"open_issues":197,"watchers":3289,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/kafka/pulls/1536"},"html":{"href":"https://github.com/apache/kafka/pull/1536"},"issue":{"href":"https://api.github.com/repos/apache/kafka/issues/1536"},"comments":{"href":"https://api.github.com/repos/apache/kafka/issues/1536/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/kafka/pulls/1536/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/kafka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/kafka/pulls/1536/commits"},"statuses":{"href":"https://api.github.com/repos/apache/kafka/statuses/843026de9c224235fe46f3fc0e882cfd4f4fbf15"}}}}
{"actor":{"display_login":"vahidhashemian"}}