{"action":"closed","issue":{"url":"https://api.github.com/repos/vert-x3/vertx-kafka-client/issues/81","repository_url":"https://api.github.com/repos/vert-x3/vertx-kafka-client","labels_url":"https://api.github.com/repos/vert-x3/vertx-kafka-client/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/vert-x3/vertx-kafka-client/issues/81/comments","events_url":"https://api.github.com/repos/vert-x3/vertx-kafka-client/issues/81/events","html_url":"https://github.com/vert-x3/vertx-kafka-client/issues/81","id":275478467,"number":81,"title":"NullPointerException when committed() called if there are no existing committed offsets present for the consumer group","user":{"login":"tinselspoon","id":9112859,"avatar_url":"https://avatars3.githubusercontent.com/u/9112859?v=4","gravatar_id":"","url":"https://api.github.com/users/tinselspoon","html_url":"https://github.com/tinselspoon","followers_url":"https://api.github.com/users/tinselspoon/followers","following_url":"https://api.github.com/users/tinselspoon/following{/other_user}","gists_url":"https://api.github.com/users/tinselspoon/gists{/gist_id}","starred_url":"https://api.github.com/users/tinselspoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinselspoon/subscriptions","organizations_url":"https://api.github.com/users/tinselspoon/orgs","repos_url":"https://api.github.com/users/tinselspoon/repos","events_url":"https://api.github.com/users/tinselspoon/events{/privacy}","received_events_url":"https://api.github.com/users/tinselspoon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-20T19:55:50Z","updated_at":"2017-11-21T13:24:28Z","closed_at":"2017-11-21T13:24:28Z","author_association":"NONE","body":"When calling `committed()` to retrieve the offsets for a consumer group, a `NullPointerException` may be thrown if the consumer group has not yet committed any offsets for that partition. This can be replicated by creating a consumer with a previously unseen group ID, and doing something like the following.\r\n\r\n```java\r\nconsumer.partitionsAssignedHandler(partitions -> {\r\n    for (final TopicPartition partition : partitions) {\r\n        consumer.committed(partition, System.out::println);\r\n    }\r\n});\r\n```\r\nThis will produce a NPE:\r\n```\r\nERROR io.vertx.core.impl.ContextImpl - Unhandled exception\r\njava.lang.NullPointerException: null\r\n\tat io.vertx.kafka.client.common.impl.Helper.from(Helper.java:97)\r\n\tat io.vertx.kafka.client.consumer.impl.KafkaConsumerImpl.lambda$committed$7(KafkaConsumerImpl.java:370)\r\n\tat io.vertx.kafka.client.consumer.impl.KafkaReadStreamImpl.lambda$null$1(KafkaReadStreamImpl.java:117)\r\n\tat io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:344)\r\n\tat io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)\r\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n```\r\n\r\nThe code that is causing the issue appears to be in `KafkaConsumerImpl`:\r\n```java\r\nif (done.succeeded()) {\r\n    handler.handle(Future.succeededFuture(Helper.from(done.result())));\r\n}\r\n```\r\nWhen `result()` is `null` in the case where no offsets are committed and `Helper.from` assumes the object is non-null."}}
{"actor":{"display_login":"ppatierno"}}