[
https://issues.apache.org/jira/browse/KAFKA-3075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15123710#comment-15123710
]
ASF GitHub Bot commented on KAFKA-3075:
---------------------------------------
GitHub user ijuma opened a pull request:
https://github.com/apache/kafka/pull/833
KAFKA-3075; Fix ClassCastException in
`ZookeeperConsumerConnector.commitOffsets`
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ijuma/kafka
kafka-3075-javaapi-consumer-class-cast-exception
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/kafka/pull/833.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #833
----
commit 2391fcb2cce2f4abcf9c4084c4f2cd45e1b0a88b
Author: Ismael Juma <[email protected]>
Date: 2016-01-29T16:32:51Z
Fix ClassCastException in `ZookeeperConsumerConnector.commitOffsets`
----
> java.util.HashMap cannot be cast to scala.collection.immutable.Map When using
> ZookeeperConsumerConnector.commitOffsets
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-3075
> URL: https://issues.apache.org/jira/browse/KAFKA-3075
> Project: Kafka
> Issue Type: Bug
> Components: consumer
> Reporter: Pengwei
> Assignee: Ismael Juma
> Fix For: 0.9.0.1
>
>
> When using java api's commit offset :
> public void commitOffsets(Map<TopicAndPartition, OffsetAndMetadata>
> offsetsToCommit, boolean retryOnFailure);
> and pass a Java Hash Map to this interface, will found:
> java.lang.ClassCastException: java.util.HashMap cannot be cast to
> scala.collection.immutable.Map
> at
> kafka.javaapi.consumer.ZookeeperConsumerConnector.commitOffsets(ZookeeperConsumerConnector.scala:118)
> at
> kafka.examples.CommitExceptionTest.testCommitNotExistTopicShoudThrowException(CommitExceptionTest.java:55)
> at kafka.examples.CommitExceptionTest.main(CommitExceptionTest.java:20)
> Test case testCommitNotExistTopicShoudThrowException OK.
> Exception in thread "main" java.lang.ClassCastException: java.util.HashMap
> cannot be cast to scala.collection.immutable.Map
> at
> kafka.javaapi.consumer.ZookeeperConsumerConnector.commitOffsets(ZookeeperConsumerConnector.scala:118)
> at
> kafka.examples.CommitExceptionTest.testCommitOffsetOutOfRange(CommitExceptionTest.java:95)
> at kafka.examples.CommitExceptionTest.main(CommitExceptionTest.java:22)
> The Origin Code:
> def commitOffsets(offsetsToCommit: java.util.Map[TopicAndPartition,
> OffsetAndMetadata], retryOnFailure: Boolean) {
>
> underlying.commitOffsets(offsetsToCommit.asInstanceOf[immutable.Map[TopicAndPartition,
> OffsetAndMetadata]], retryOnFailure)
> }
> I try to fix like this, it is OK:
> def commitOffsets(offsetsToCommit: java.util.Map[TopicAndPartition,
> OffsetAndMetadata], retryOnFailure: Boolean) {
> import scala.collection.JavaConverters._
> underlying.commitOffsets(offsetsToCommit.asScala.toMap, retryOnFailure)
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)