AvroFile avroFile = it.next().getValue();
if (!avroFile.isOpen()) {
it.remove();
} else {
avroFile.sync();
<BUG>if (currentTs - avroFile.getLastModifiedTs() > inactiveIntervalMs) {
avroFile.close();</BUG>
it.remove();
}
}

AvroFile avroFile = it.next().getValue();
if (!avroFile.isOpen()) {
it.remove();
} else {
avroFile.sync();
long timeSinceFileCreate = currentTs - avroFile.getCreateTime();
if (timeSinceFileCreate > maxFileLifetimeMs) {
avroFile.close();
it.remove();
