[KAFKA-161] MongoSourceTask.poll NullPointerException Created: 21/Sep/20  Updated: 02/Jun/22  Resolved: 22/Sep/20

Status: Closed
Project: Kafka Connector
Component/s: Source
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrey B Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File reproduce-kafka-161.patch    

 Description   

java.lang.NullPointerExceptionjava.lang.NullPointerException at com.mongodb.kafka.connect.source.MongoSourceTask.poll(MongoSourceTask.java:213) at org.apache.kafka.connect.runtime.WorkerSourceTask.poll(WorkerSourceTask.java:272) at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:239) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:184) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:234) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

I guess it's because heartbeatManager not creating in com.mongodb.kafka.connect.source.MongoSourceTask#start if shouldCopyData()=true.
So, in such case heartbeatManager.heartbeat() could be called when heartbeatManager not created yet.

 

Found this error in the last master.



 Comments   
Comment by Andrey B [ 22/Sep/20 ]

I've attached a patch which makes testSourceUsesHeartbeatsForOffsets fails with such NullPointerException

 

Thanks for fix

Comment by Ross Lawley [ 22/Sep/20 ]

Hi andreworty@gmail.com,

If possible it would be good to get a a minimal, reproducible example of this error, so I can write a regression test. I'm happy its fixed but it would be nice to have.

Thanks again, for all your feedback and for kicking the tires of the forthcoming new connector release.

Ross

Comment by Ross Lawley [ 22/Sep/20 ]

Hi andreworty@gmail.com,

I couldn't replicate the error and thought that it was caught previously as it aligns when the cursor is closed. However, I've added a defensive block to ensure no NPE's.

Ross

Comment by Githook User [ 22/Sep/20 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: Defensively handle the heartbeat manager

Also ensure its reset on restart.

KAFKA-161
Branch: master
https://github.com/mongodb/mongo-kafka/commit/be9b6d82ce00498e1912e5df792d468194051eb1

Generated at Thu Feb 08 09:05:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.