ijuma commented on code in PR #18371:
URL: https://github.com/apache/kafka/pull/18371#discussion_r1904765210
##########
connect/api/src/main/java/org/apache/kafka/connect/data/SchemaProjector.java:
##########
@@ -78,25 +79,13 @@ public static Object project(Schema source, Object record,
Schema target) throws
}
private static Object projectRequiredSchema(Schema source, Object record,
Schema target) throws SchemaProjectorException {
- switch (target.type()) {
- case INT8:
- case INT16:
- case INT32:
- case INT64:
- case FLOAT32:
- case FLOAT64:
- case BOOLEAN:
- case BYTES:
- case STRING:
- return projectPrimitive(source, record, target);
- case STRUCT:
- return projectStruct(source, (Struct) record, target);
- case ARRAY:
- return projectArray(source, record, target);
- case MAP:
- return projectMap(source, record, target);
- }
- return null;
Review Comment:
This was directly translated by IntelliJ - I started (but haven't completed)
the review of every case to make sure it makes sense. Generally speaking, if
the switch is exhaustive, then it doesn't need to return `null` if we're ok
with throwing an exception if a new enum element is added later and the code is
not updated.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]