ahmedahamid commented on a change in pull request #2833: [GOBBLIN-987] Reject
unrecognized Enum symbols in JsonRecordAvroSchemaToAvroConverter
URL: https://github.com/apache/incubator-gobblin/pull/2833#discussion_r351953747
##########
File path:
gobblin-core/src/main/java/org/apache/gobblin/converter/avro/JsonElementConversionWithAvroSchemaFactory.java
##########
@@ -165,7 +166,10 @@ public EnumConverter(String fieldName, boolean nullable,
String sourceType, Sche
@Override
Object convertField(JsonElement value) {
- return new GenericData.EnumSymbol(this.schema, value.getAsString());
+ String valueString = value.getAsString();
+ Validate.isTrue(this.enumSet.contains(valueString),
Review comment:
No problem. The code already has a dependency on commons lang3 (I checked
the `build.gradle` of the `gobblin-core` module) but I do agree regarding
consistency.
One more thing: I had to make a tiny change to line #162 in
`JsonElementConversionWithAvroSchemaFactory.java` because the code wasn't
picking the enum name correctly. It was retrieving the type name instead, which
is always `enum`. So, now the exception message reads as follows
```
PURPLE is not one of the valid symbols for the
org.apache.gobblin.test.Colors enum: [RED, GREEN, BLUE]
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services