You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jason Gustafson (JIRA)" <ji...@apache.org> on 2018/06/05 23:09:00 UTC
[jira] [Comment Edited] (KAFKA-6994) KafkaConsumer.poll throwing
AuthorizationException timeout-dependent
[ https://issues.apache.org/jira/browse/KAFKA-6994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16502631#comment-16502631 ]
Jason Gustafson edited comment on KAFKA-6994 at 6/5/18 11:08 PM:
-----------------------------------------------------------------
Yes, the consumer does not block to await metadata in `poll(long)`. The `poll(50)` may or may not return before completing the Metadata request returns.
was (Author: hachikuji):
Yes, the consumer does not block to await. The `poll(50)` may or may not return before completing the Metadata request returns.
> KafkaConsumer.poll throwing AuthorizationException timeout-dependent
> --------------------------------------------------------------------
>
> Key: KAFKA-6994
> URL: https://issues.apache.org/jira/browse/KAFKA-6994
> Project: Kafka
> Issue Type: Bug
> Reporter: Edoardo Comar
> Priority: Minor
>
> With auto-topic creation enabled, when attempting to consume from a non-existent topic, theĀ {{AuthorizationException}} may or may not be thrown from {{poll(timeout)}} depending on the {{timeout}} value.
> The issue can be recreated modifying a test in {{AuthorizerIntegrationTest}} as below (see comment) to *not* add the needed acl and therefore expecting the test to fail.
> While the first {{poll}} call will always throw with a short timeout, the second {{poll}} will not throw with the short timeout.
> {code:java}
> @Test
> def testCreatePermissionOnClusterToReadFromNonExistentTopic() {
> testCreatePermissionNeededToReadFromNonExistentTopic("newTopic",
> Set(new Acl(userPrincipal, Allow, Acl.WildCardHost, Create)),
> Cluster)
> }
> private def testCreatePermissionNeededToReadFromNonExistentTopic(newTopic: String, acls: Set[Acl], resType: ResourceType) {
> val topicPartition = new TopicPartition(newTopic, 0)
> val newTopicResource = new Resource(Topic, newTopic)
> addAndVerifyAcls(Set(new Acl(userPrincipal, Allow, Acl.WildCardHost, Read)), newTopicResource)
> addAndVerifyAcls(groupReadAcl(groupResource), groupResource)
> this.consumers.head.assign(List(topicPartition).asJava)
> try {
> this.consumers.head.poll(Duration.ofMillis(50L));
> Assert.fail("should have thrown Authorization Exception")
> } catch {
> case e: TopicAuthorizationException =>
> assertEquals(Collections.singleton(newTopic), e.unauthorizedTopics())
> }
> //val resource = if (resType == Topic) newTopicResource else Resource.ClusterResource
> // addAndVerifyAcls(acls, resource)
> // need to use a larger timeout in this subsequent poll else it may not cause topic auto-creation
> // this can be verified by commenting the above addAndVerifyAcls line and expecting this test to fail
> this.consumers.head.poll(Duration.ofMillis(50L));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)