Skip to content

Commit 0d687fa

Browse files
committed
Do not attempt to read empty files (fixes #3)
1 parent d124fa2 commit 0d687fa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/radarcns/RestructureAvroRecords.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ private void processFile(Path filePath, String topicName, FileCacheStore cache,
197197

198198
// Read and parse avro file
199199
FsInput input = new FsInput(filePath, conf);
200+
201+
// processing zero-length files may trigger a stall. See:
202+
// https://github.com/RADAR-CNS/Restructure-HDFS-topic/issues/3
203+
if (input.length() == 0) {
204+
logger.warn("File {} has zero length, skipping.", filePath);
205+
return;
206+
}
207+
200208
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(input,
201209
new GenericDatumReader<>());
202210

0 commit comments

Comments
 (0)