[
https://issues.apache.org/jira/browse/GOBBLIN-923?focusedWorklogId=332374&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-332374
]
ASF GitHub Bot logged work on GOBBLIN-923:
------------------------------------------
Author: ASF GitHub Bot
Created on: 23/Oct/19 02:06
Start Date: 23/Oct/19 02:06
Worklog Time Spent: 10m
Work Description: ahmedahamid commented on pull request #2779:
[GOBBLIN-923] Fix Array and Map JsonElement converters to handle nullable
elements
URL: https://github.com/apache/incubator-gobblin/pull/2779
Dear Gobblin maintainers,
Please accept this PR. I understand that it will not be reviewed until I
have checked off all the steps below!
### JIRA
- [ GOBBLIN-923] My PR addresses the following [Gobblin
JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references
them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
- https://issues.apache.org/jira/browse/GOBBLIN-923
### Description
- [x] Here are some details about my PR, including screenshots (if
applicable):
This change fixes the converters below to check if the `JsonElement`
they are invoked with is a `JsonNull` and handle it accordingly.
- `JsonElementConversionWithAvroSchemaFactory::ArrayConverter`
- `JsonElementConversionWithAvroSchemaFactory::MapConverter`
- `JsonElementConversionFactory::ArrayConverter`
- `JsonElementConversionFactory::MapConverter`
### Tests
- [x] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason:
No new functionality
### Commits
- [x] My commits all reference JIRA issues in their subject lines, and I
have squashed multiple commits if they address the same issue. In addition, my
commits follow the guidelines from "[How to write a good git commit
message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
2. Subject is limited to 50 characters
3. Subject does not end with a period
4. Subject uses the imperative mood ("add", not "adding")
5. Body wraps at 72 characters
6. Body explains "what" and "why", not "how"
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 332374)
Remaining Estimate: 0h
Time Spent: 10m
> Array and Map converters do not handle nullable elements properly
> -----------------------------------------------------------------
>
> Key: GOBBLIN-923
> URL: https://issues.apache.org/jira/browse/GOBBLIN-923
> Project: Apache Gobblin
> Issue Type: Bug
> Reporter: Ahmed Abdul Hamid
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The following converters do not check if the {{JsonElement}} objects they are
> invoked with are {{JsonNull}} even if these elements are nullable.
> * {{JsonElementConversionWithAvroSchemaFactory::ArrayConverter}}
> * {{JsonElementConversionWithAvroSchemaFactory::MapConverter}}
> * {{JsonElementConversionFactory::ArrayConverter}}
> * {{JsonElementConversionFactory::MapConverter}}
> This can cause these converters to throw {{UnsupportedOperationException}},
> e.g. an {{ArrayConverter}} invoked with an array of nullable strings throws
> {code:java}
> Caused by: java.lang.UnsupportedOperationException: JsonNull
> at com.google.gson.JsonElement.getAsString(JsonElement.java:192)
> ~[gson-2.8.5.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonElementConversionFactory$StringConverter.convertField(JsonElementConversionFactory.java:322)
> ~[gobblin-core-1.64.1501.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonElementConversionWithAvroSchemaFactory$ArrayConverter.convertField(JsonElementConversionWithAvroSchemaFactory.java:93)
> ~[gobblin-core-1.64.1501.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonElementConversionFactory$JsonElementConverter.convert(JsonElementConversionFactory.java:280)
> ~[gobblin-core-1.64.1501.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonRecordAvroSchemaToAvroConverter.convertNestedRecord(JsonRecordAvroSchemaToAvroConverter.java:125)
> ~[gobblin-core-1.64.1501.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonRecordAvroSchemaToAvroConverter.convertRecord(JsonRecordAvroSchemaToAvroConverter.java:71)
> ~[gobblin-core-1.64.1501.jar:?]
> at
> org.apache.gobblin.converter.avro.JsonRecordAvroSchemaToAvroConverter.convertRecord(JsonRecordAvroSchemaToAvroConverter.java:43)
> ~[gobblin-core-1.64.1501.jar:?] {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)