iemejia commented on code in PR #3726:
URL: https://github.com/apache/avro/pull/3726#discussion_r3563385102


##########
lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java:
##########
@@ -238,4 +245,36 @@ void invalidMagicBytes() throws IOException {
           () -> DataFileReader.openReader(fileInput, new 
GenericDatumReader<>()));
     }
   }
+
+  @Test
+  void missingSchemaMetadataDoesNotThrowNullPointerException() throws 
IOException {
+    byte[] malformedFile = buildContainerHeaderWithoutSchema();
+
+    IOException streamException = assertThrows(IOException.class,
+        () -> new DataFileStream<>(new ByteArrayInputStream(malformedFile), 
new GenericDatumReader<>()));
+    assertNotNull(streamException.getMessage());
+    
assertTrue(streamException.getMessage().contains(DataFileConstants.SCHEMA));
+
+    IOException readerException = assertThrows(IOException.class,

Review Comment:
   Good point - the existing test only covers `DataFileStream` and 
`DataFileReader` (current format). It does not exercise `DataFileReader12` 
since that class uses a different binary layout (footer-based metadata).
   
   I've now added a dedicated test 
(`missingSchemaMetadataInVersion12DoesNotThrowNullPointerException`) that 
constructs a minimal Avro 1.2 format container with the sync marker but no 
schema entry, and asserts that `DataFileReader12` throws a descriptive 
`IOException` rather than an NPE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to