[KAFKA-227] NullPointerException when returning null from a custom WriteModelStrategy Created: 27/May/21 Updated: 28/Oct/23 Resolved: 01/Jun/21 |
|
| Status: | Closed |
| Project: | Kafka Connector |
| Component/s: | Sink |
| Affects Version/s: | 1.5.0 |
| Fix Version/s: | 1.5.1 |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Diego Díez | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Returning null from a custom WriteModelStrategy (as documented in https://docs.mongodb.com/kafka-connector/current/kafka-sink-postprocessors/#:~:text=Return%20null%20to%20indicate%20no%20op) throws a NullPointerException when trying to wrap the returned value in a java.util.Optional.
The fix seems trivial: Use Optional.ofNullable(value) instead of Optional.of(value) |
| Comments |
| Comment by Githook User [ 28/May/21 ] |
|
Author: {'name': 'Diego Díez', 'email': 'diegodiez.ddr@gmail.com', 'username': 'didiez'}Message: Wrap nullable value returned from WriteModelStrategy using Optional.ofNullable(value)
|
| Comment by Githook User [ 28/May/21 ] |
|
Author: {'name': 'Diego Díez', 'email': 'diegodiez.ddr@gmail.com', 'username': 'didiez'}Message: fixes |
| Comment by Githook User [ 28/May/21 ] |
|
Author: {'name': 'Diego Díez', 'email': 'diegodiez.ddr@gmail.com', 'username': 'didiez'}Message: fixes |
| Comment by Diego Díez [ 27/May/21 ] |
|
Great! I forgot to comment here after sending the PR https://github.com/mongodb/mongo-kafka/pull/70 with the fix. |
| Comment by Ross Lawley [ 27/May/21 ] |
|
Thanks for the ticket, this will be fixed in the next release. Ross |