diff --git a/src/Microsoft.Hadoop.Avro/Serializers/UnionSerializer.cs b/src/Microsoft.Hadoop.Avro/Serializers/UnionSerializer.cs index db3f920..a656288 100644 --- a/src/Microsoft.Hadoop.Avro/Serializers/UnionSerializer.cs +++ b/src/Microsoft.Hadoop.Avro/Serializers/UnionSerializer.cs @@ -62,8 +62,8 @@ protected override Expression BuildDeserializerSafe(Expression decoder) ParameterExpression resultParameter = Expression.Variable(this.Schema.RuntimeType, "result"); ParameterExpression unionTypeParameter = Expression.Variable(typeof(int), "unionType"); BinaryExpression assignUnionType = Expression.Assign(unionTypeParameter, Expression.Call(decoder, this.Decode(), new Expression[] { })); - - Expression elseBranch = Expression.Empty(); + + Expression elseBranch = Expression.Assign(resultParameter, Expression.Convert(Expression.Constant(null), this.Schema.RuntimeType)); ConditionalExpression conditions = null; for (int i = this.itemSchemas.Count - 1; i >= 0; i--) {