Skip to content

Commit ee9586c

Browse files
committed
AVRO-4170: Improve sync marker error message in DataFileStream
1 parent 0606c33 commit ee9586c

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ DataBlock nextRawBlock(DataBlock reuse) throws IOException {
330330
vin.readFixed(syncBuffer);
331331
availableBlock = false;
332332
if (!Arrays.equals(syncBuffer, header.sync))
333-
throw new IOException("Invalid sync!");
333+
throw new IOException("Invalid sync marker! The sync marker in the data block doesn't match the "
334+
+ "file header's sync marker. This likely indicates data corruption, truncated file, "
335+
+ "or incorrectly concatenated Avro files. Verify file integrity and ensure proper "
336+
+ "file transmission or creation.");
334337
return reuse;
335338
}
336339

lang/java/avro/src/test/java/org/apache/avro/TestDataFileCorruption.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ void corruptedFile() throws IOException {
8787
assertEquals("fig", r.next().toString());
8888
assertFalse(r.hasNext());
8989
} catch (AvroRuntimeException e) {
90-
assertEquals("Invalid sync!", e.getCause().getMessage());
90+
assertEquals("Invalid sync marker! The sync marker in the data block doesn't match the "
91+
+ "file header's sync marker. This likely indicates data corruption, truncated file, "
92+
+ "or incorrectly concatenated Avro files. Verify file integrity and ensure proper "
93+
+ "file transmission or creation.", e.getCause().getMessage());
9194
}
9295

9396
}

0 commit comments

Comments
 (0)