Efrat19 commented on code in PR #171:
URL: 
https://github.com/apache/flink-connector-kafka/pull/171#discussion_r2659457226


##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/sink/KafkaRecordSerializationSchemaBuilder.java:
##########
@@ -432,13 +433,17 @@ public Optional<TypeDatasetFacet> getTypeDatasetFacet() {
                                 ((ResultTypeQueryable<?>) 
this.valueSerializationSchema)
                                         .getProducedType()));
             } else {
-                // gets type information from serialize method signature
-                Type type =
-                        TypeExtractor.getParameterType(
-                                SerializationSchema.class, 
valueSerializationSchema.getClass(), 0);
                 try {
+                    Type type =
+                            TypeExtractor.getParameterType(
+                                    SerializationSchema.class,
+                                    valueSerializationSchema.getClass(),
+                                    0);
+
                     return Optional.of(
                             new 
DefaultTypeDatasetFacet(TypeExtractor.createTypeInfo(type)));
+                } catch (InvalidTypesException e) {

Review Comment:
   Wouldn't a type check beforehand be less expensive resource-wise? (Depending 
on how often do you expect to hit this fallback)



##########
flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/DynamicKafkaRecordSerializationSchema.java:
##########
@@ -211,12 +212,14 @@ public Optional<TypeDatasetFacet> getTypeDatasetFacet() {
                     new DefaultTypeDatasetFacet(
                             ((ResultTypeQueryable<?>) 
this.valueSerialization).getProducedType()));
         } else {
-            // gets type information from serialize method signature
-            Type type =
-                    TypeExtractor.getParameterType(
-                            SerializationSchema.class, 
valueSerialization.getClass(), 0);
             try {
+                Type type =
+                        TypeExtractor.getParameterType(
+                                SerializationSchema.class, 
valueSerialization.getClass(), 0);
+
                 return Optional.of(new 
DefaultTypeDatasetFacet(TypeExtractor.createTypeInfo(type)));
+            } catch (InvalidTypesException e) {

Review Comment:
   Same as 
https://github.com/apache/flink-connector-kafka/pull/171/changes#r2659457226



-- 
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]

Reply via email to