You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Brian Walshe (JIRA)" <ji...@apache.org> on 2018/12/03 23:25:00 UTC
[jira] [Created] (AVRO-2280) Calling DataFileWriter::flush() when
there is no data to write can subsequently cause an exception when the file
is read
Brian Walshe created AVRO-2280:
----------------------------------
Summary: Calling DataFileWriter::flush() when there is no data to write can subsequently cause an exception when the file is read
Key: AVRO-2280
URL: https://issues.apache.org/jira/browse/AVRO-2280
Project: Apache Avro
Issue Type: Bug
Components: c++
Reporter: Brian Walshe
If you call flush() on a DataFileWriter object that has no data waiting to be written, this will produce an empty block at the end of the file which will cause an exception on the last call to DataFileReader::read(T& datum)
h2. Example
For example adding the following to the Data File unit tests will cause them to break [https://github.com/bwalshe/avro/blob/7c6a229b2fcbb0b88368e1503a58daef9f43ee64/lang/c%2B%2B/test/DataFileTests.cc#L192]
h2. Possible Solution
Altering DataFileWriter::sync() to check if there are objects to be written before proceeding will get the code to pass the unit tests. e.g.: [https://github.com/bwalshe/avro/blob/7c6a229b2fcbb0b88368e1503a58daef9f43ee64/lang/c%2B%2B/impl/DataFile.cc#L141 |https://github.com/bwalshe/avro/blob/7c6a229b2fcbb0b88368e1503a58daef9f43ee64/lang/c%2B%2B/impl/DataFile.cc#L141]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)