vamossagar12 commented on PR #12321:
URL: https://github.com/apache/kafka/pull/12321#issuecomment-1163357345

   > LGTM! (With some non-blocker suggestions)
   > 
   > I wonder if there are some higher-level fixes we might also adopt that 
would make NPEs from method references harder to write. Some ideas that come to 
mind:
   > 
   > 1. Stop using method references where possible and start actually 
implementing the `AutoCloseable` interface (this seems reasonable for the 
`*BackingStore` interfaces given that they already have stop() methods that 
behave closely to `AutoCloseable::close`, for example).
   > 2. Add a new variant to `Utils::closeQuietly` that accepts a possibly-null 
object and some kind of consumer that can be applied to that object if it's 
non-null that will close it; I'm imagining calling it would look something like 
`closeQuietly(producer, p -> p.close(duration), "source task producer");` 
instead of the [existing 
logic](https://github.com/apache/kafka/blob/3072b3d23e43f3bc3478eca1087312edb620dc6b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTask.java#L317-L319)
 for closing a source task's producer, or `closeQuietly(offsetStore, 
OffsetBackingStore::stop, "offset backing store")` instead of the [existing 
logic](https://github.com/apache/kafka/blob/3072b3d23e43f3bc3478eca1087312edb620dc6b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTask.java#L313)
 for stopping a source task's offset store.
   
   Thanks. I was actually thinking about something like option #2 but then when 
I saw, there are changes needed at only a couple of places, I didn't proceed. 
Do you think we can have a follow up ticket for this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to