Skip to content

Commit

Permalink
[BuxFix] [Kafka-Connector] Fixed null pointer issue when kafka uses j…
Browse files Browse the repository at this point in the history
…son to read datetime type encountering null values
  • Loading branch information
LeonYoah committed Jul 10, 2024
1 parent 57e5627 commit 0a8e618
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ private float convertToFloat(JsonNode jsonNode) {
}

private LocalDate convertToLocalDate(JsonNode jsonNode, String fieldName) {
if ("".equals(jsonNode.asText())) {
return null;
}
String dateStr = jsonNode.asText();
DateTimeFormatter dateFormatter = fieldFormatterMap.get(fieldName);
if (dateFormatter == null) {
Expand All @@ -261,11 +264,17 @@ private LocalDate convertToLocalDate(JsonNode jsonNode, String fieldName) {
}

private LocalTime convertToLocalTime(JsonNode jsonNode) {
if ("".equals(jsonNode.asText())) {
return null;
}
TemporalAccessor parsedTime = TIME_FORMAT.parse(jsonNode.asText());
return parsedTime.query(TemporalQueries.localTime());
}

private LocalDateTime convertToLocalDateTime(JsonNode jsonNode, String fieldName) {
if ("".equals(jsonNode.asText())) {
return null;
}
String datetimeStr = jsonNode.asText();
DateTimeFormatter dateTimeFormatter = fieldFormatterMap.get(fieldName);
if (dateTimeFormatter == null) {
Expand Down

0 comments on commit 0a8e618

Please sign in to comment.