You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/03/29 10:29:55 UTC

[avro] branch branch-1.11 updated: Move CanRead to constructor (#1625)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 5fddcd2  Move CanRead to constructor (#1625)
5fddcd2 is described below

commit 5fddcd2a24ee9d368aacaf861d27aaa538709a90
Author: Zoltan Csizmadia <zc...@gmail.com>
AuthorDate: Tue Mar 29 02:55:12 2022 -0500

    Move CanRead to constructor (#1625)
    
    Co-authored-by: Zoltan Csizmadia <Cs...@valassis.com>
    (cherry picked from commit 565849d05f768f5fc249711dc26bde0c9f68699b)
---
 lang/csharp/src/apache/main/Generic/GenericReader.cs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lang/csharp/src/apache/main/Generic/GenericReader.cs b/lang/csharp/src/apache/main/Generic/GenericReader.cs
index f42e572..8c9e967 100644
--- a/lang/csharp/src/apache/main/Generic/GenericReader.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericReader.cs
@@ -121,6 +121,8 @@ namespace Avro.Generic
         {
             this.ReaderSchema = readerSchema;
             this.WriterSchema = writerSchema;
+            if (!ReaderSchema.CanRead(WriterSchema))
+                throw new AvroException("Schema mismatch. Reader: " + ReaderSchema + ", writer: " + WriterSchema);
         }
 
         /// <summary>
@@ -134,9 +136,6 @@ namespace Avro.Generic
         /// <returns>Object read from the decoder.</returns>
         public T Read<T>(T reuse, Decoder decoder)
         {
-            if (!ReaderSchema.CanRead(WriterSchema))
-                throw new AvroException("Schema mismatch. Reader: " + ReaderSchema + ", writer: " + WriterSchema);
-
             return (T)Read(reuse, WriterSchema, ReaderSchema, decoder);
         }