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

opwvhk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/main by this push:
     new 6db1f79e22 AVRO-4170: Improve sync marker error message in 
DataFileStream (#3446)
6db1f79e22 is described below

commit 6db1f79e22e8558ac0455cf73f6e1fb7d1139f44
Author: Yuming Wang <[email protected]>
AuthorDate: Thu Sep 11 18:57:14 2025 +0800

    AVRO-4170: Improve sync marker error message in DataFileStream (#3446)
---
 .../java/avro/src/main/java/org/apache/avro/file/DataFileStream.java | 5 ++++-
 .../avro/src/test/java/org/apache/avro/TestDataFileCorruption.java   | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
index 2bb24b3fa1..e2e79d8eae 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
@@ -330,7 +330,10 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
     vin.readFixed(syncBuffer);
     availableBlock = false;
     if (!Arrays.equals(syncBuffer, header.sync))
-      throw new IOException("Invalid sync!");
+      throw new IOException("Invalid sync marker! The sync marker in the data 
block doesn't match the "
+          + "file header's sync marker. This likely indicates data corruption, 
truncated file, "
+          + "or incorrectly concatenated Avro files. Verify file integrity and 
ensure proper "
+          + "file transmission or creation.");
     return reuse;
   }
 
diff --git 
a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileCorruption.java 
b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileCorruption.java
index e4659488d1..1a8d54f301 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/TestDataFileCorruption.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/TestDataFileCorruption.java
@@ -87,7 +87,10 @@ public class TestDataFileCorruption {
       assertEquals("fig", r.next().toString());
       assertFalse(r.hasNext());
     } catch (AvroRuntimeException e) {
-      assertEquals("Invalid sync!", e.getCause().getMessage());
+      assertEquals("Invalid sync marker! The sync marker in the data block 
doesn't match the "
+          + "file header's sync marker. This likely indicates data corruption, 
truncated file, "
+          + "or incorrectly concatenated Avro files. Verify file integrity and 
ensure proper "
+          + "file transmission or creation.", e.getCause().getMessage());
     }
 
   }

Reply via email to