Skip to content

Commit

Permalink
Added handeling for null values
Browse files Browse the repository at this point in the history
  • Loading branch information
oryanmoshe committed Apr 21, 2020
1 parent 1f92735 commit a946446
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>oryanmoshe.kafka.connect.util</groupId>
<artifactId>TimestampConverter</artifactId>
<packaging>jar</packaging>
<version>1.1.1-SNAPSHOT</version>
<version>1.1.2-SNAPSHOT</version>
<name>TimestampConverter</name>
<url>http://maven.apache.org</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBu
if (SUPPORTED_DATA_TYPES.stream().anyMatch(s -> s.toLowerCase().equals(column.typeName().toLowerCase()))) {
boolean isTime = "time".equals(column.typeName().toLowerCase());
registration.register(datetimeSchema, rawValue -> {
if (rawValue == null)
return rawValue;

Long millis = getMillis(rawValue.toString(), isTime);
if (millis == null)
return rawValue.toString();
Expand All @@ -89,7 +92,7 @@ public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBu
}

private Long getMillis(String timestamp, boolean isTime) {
if (timestamp == null || timestamp.isBlank())
if (timestamp.isBlank())
return null;

if (timestamp.contains(":") || timestamp.contains("-")) {
Expand Down

0 comments on commit a946446

Please sign in to comment.