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/30 06:25:28 UTC

[avro] branch branch-1.11 updated: [AVRO-3460] follow up: reusing NameRef (#1627)

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 1324c68  [AVRO-3460] follow up: reusing NameRef (#1627)
1324c68 is described below

commit 1324c6880f1127616dd4212ac926cc1ae6e96c5a
Author: Jack Klamer <jf...@gmail.com>
AuthorDate: Wed Mar 30 01:25:04 2022 -0500

    [AVRO-3460] follow up: reusing NameRef (#1627)
    
    (cherry picked from commit 52abb50949e8d1933c7209f97d7bff5d8a20075d)
---
 lang/rust/avro/src/types.rs  | 2 +-
 lang/rust/avro/src/writer.rs | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lang/rust/avro/src/types.rs b/lang/rust/avro/src/types.rs
index cd00b7c..a88bdae 100644
--- a/lang/rust/avro/src/types.rs
+++ b/lang/rust/avro/src/types.rs
@@ -337,7 +337,7 @@ impl Value {
         self.validate_internal(schema, rs.get_names())
     }
 
-    fn validate_internal(&self, schema: &Schema, names: &NamesRef) -> bool {
+    pub(crate) fn validate_internal(&self, schema: &Schema, names: &NamesRef) -> bool {
         match (self, schema) {
             (_, &Schema::Ref { ref name }) => names
                 .get(name)
diff --git a/lang/rust/avro/src/writer.rs b/lang/rust/avro/src/writer.rs
index 23d53ee..6bb37f7 100644
--- a/lang/rust/avro/src/writer.rs
+++ b/lang/rust/avro/src/writer.rs
@@ -357,7 +357,10 @@ fn write_value_ref_resolved(
     value: &Value,
     buffer: &mut Vec<u8>,
 ) -> AvroResult<()> {
-    if !value.validate(resolved_schema.get_root_schema()) {
+    if !value.validate_internal(
+        resolved_schema.get_root_schema(),
+        resolved_schema.get_names(),
+    ) {
         return Err(Error::Validation);
     }
     encode_internal(