opwvhk commented on a change in pull request #1277:
URL: https://github.com/apache/avro/pull/1277#discussion_r778815057
##########
File path:
lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
##########
@@ -855,3 +856,23 @@ $I } else {
#set ($I = $this.indent($indent))
$I }
#end
+
+#macro( assignField $field $schema)
+#set($I = $this.indent(6))
+#if ($this.shouldBeDeserializedFromString($field.schema()))
+#if ($this.constructorThrowsCheckedException($field.schema()))
+$I try {
+#end
+$I if (null != value$) {
+$I ${this.mangle($field.name(), $schema.isError())} = new
${this.javaType($field.schema())}(value$.toString());
+$I }
+#if ($this.constructorThrowsCheckedException($field.schema()))
+$I } catch (java.lang.Exception e) {
+$I throw new org.apache.avro.AvroRuntimeException(e);
+$I }
+#end
+#else
+$I ${this.mangle($field.name(), $schema.isError())} =
#if(${this.javaType($field.schema())} != "java.lang.Object" &&
${this.javaType($field.schema())} !=
"java.lang.String")(${this.javaType($field.schema())})#{end}value$#if(${this.javaType($field.schema())}
== "java.lang.String") != null ? value$.toString() : null#{end};
Review comment:
Thank you for the verbatim copy of the original code; that makes reading
the change a lot easier.
--
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]