prestodb/presto · warning · UncheckedIOException
Failed to close ByteArrayOutputStream
Error message
Failed to close ByteArrayOutputStream
What it means
AvroRowEncoder.close() wraps any IOException thrown while closing the underlying ByteArrayOutputStream into an UncheckedIOException. ByteArrayOutputStream.close() is documented as a no-op and practically never throws, so this guard exists purely to satisfy the Closeable contract of the RowEncoder interface and shield callers from checked exceptions.
Source
Thrown at presto-kafka/src/main/java/com/facebook/presto/kafka/encoder/avro/AvroRowEncoder.java:157
dataFileWriter.append(record);
dataFileWriter.close();
resetColumnIndex(); // reset currentColumnIndex to prepare for next row
return byteArrayOutputStream.toByteArray();
}
catch (IOException e) {
throw new UncheckedIOException("Failed to append record", e);
}
}
@Override
public void close()
{
try {
byteArrayOutputStream.close();
}
catch (IOException e) {
throw new UncheckedIOException("Failed to close ByteArrayOutputStream", e);
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- No action needed: the underlying ByteArrayOutputStream.close() is a no-op and cannot realistically fail.
- If it ever surfaces, inspect the wrapped IOException cause for an unusual OutputStream subclass or agent-decorated stream and fix that resource.
- Upgrade Presto, since this defensive wrapper could be simplified/silenced in newer versions.
Defensive patterns
Strategy: try-catch
Try / catch
// close() already wraps into UncheckedIOException; only needed if calling stream.close() directly
try {
encoder.close();
} catch (UncheckedIOException e) {
log.warn("Failed to close AvroRowEncoder: %s", e.getMessage(), e);
} Prevention
- Rely on ByteArrayOutputStream.close() being a no-op; do not add extra handling.
- Close encoders in try-with-resources so teardown errors surface deterministically.
- Inspect the chained cause if this error ever actually fires.
When it happens
Trigger: Calling close() on an AvroRowEncoder after encoding rows; the try/catch fires only if byteArrayOutputStream.close() throws an IOException, which for ByteArrayOutputStream effectively never happens.
Common situations: Teardown of a Kafka record encoder at the end of a query page; try-with-resources on the encoder; almost always seen only as an impossible defensive branch or during JVM-level I/O errors.
Related errors
- KAFKA_SCHEMA_ERROR
- Failed to append record
- BIGQUERY_ERROR_END_OF_AVRO_BUFFER
- BIGQUERY_ERROR_READING_NEXT_AVRO_RECORD
- Column '%s' does not support 'null' value
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8050619b584af2ea.
Report an issue: GitHub.