[
https://issues.apache.org/jira/browse/GOBBLIN-987?focusedWorklogId=350802&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-350802
]
ASF GitHub Bot logged work on GOBBLIN-987:
------------------------------------------
Author: ASF GitHub Bot
Created on: 28/Nov/19 02:46
Start Date: 28/Nov/19 02:46
Worklog Time Spent: 10m
Work Description: ahmedahamid commented on pull request #2833:
[GOBBLIN-987] Reject unrecognized Enum symbols in
JsonRecordAvroSchemaToAvroConverter
URL: https://github.com/apache/incubator-gobblin/pull/2833
This change fixes JsonRecordAvroSchemaToAvroConverter by rejecting Enum
symbols not defined in the specified Avro schema. Allowing such values
causes runtime errors when the resulting objects are encoded.
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
- [x] 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-987
### Description
- [x] Here are some details about my PR, including screenshots (if
applicable):
`JsonRecordAvroSchemaToAvroConverter` allows unrecognized Enum symbols not
declared in the specified Avro schema. Attempting to write/encode the resulting
objects cause runtime errors that are difficult to diagnose or root-cause.
### Tests
- [x] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason:
`org.apache.gobblin.converter.avro.JsonRecordAvroSchemaToAvroConverterTest.testConverterThrowsOnUnrecognizedEnumSymbols()`
### 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: 350802)
Remaining Estimate: 0h
Time Spent: 10m
> JsonRecordAvroSchemaToAvroConverter does not reject unrecognized Enum symbols
> -----------------------------------------------------------------------------
>
> Key: GOBBLIN-987
> URL: https://issues.apache.org/jira/browse/GOBBLIN-987
> Project: Apache Gobblin
> Issue Type: Bug
> Reporter: Ahmed Abdul Hamid
> Priority: Major
> Attachments: invalid-enum-unit-test.patch
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Here is a failing unit test that demonstrates the issue we encounter when we
> attempt to encode the records produced by
> {{JsonRecordAvroSchemaToAvroConverter}} with unrecognized Enum symbols:
> [^invalid-enum-unit-test.patch]
> Here's how to apply the patch and run the test:
> {code:bash}
> $ git apply invalid-enum-unit-test.patch$
> $ ./gradlew :gobblin-core:test --tests *testEnumConversion* {code}
> Here's the output:
> {code:java}
> java.lang.NullPointerException: null of string in field fieldToIgnore of
> org.apache.gobblin.test.TestRecord
> at
> org.apache.avro.generic.GenericDatumWriter.npe(GenericDatumWriter.java:132)
> at
> org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:126)
> at
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
> at
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:60)
> at
> org.apache.gobblin.converter.avro.JsonRecordAvroSchemaToAvroConverterTest.testEnumConversion(JsonRecordAvroSchemaToAvroConverterTest.java:82)
> {code}
> The root cause of the issue that {{JsonRecordAvroSchemaToAvroConverter}}
> allows unrecognized Enum symbols not declared in the specified Avro schema.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)