flowable/flowable-engine · error · org.activiti.engine.ActivitiException
couldn't read input stream
Error message
couldn't read input stream ${inputStreamName} What it means
IoUtil.readInputStream copies an InputStream into a byte[]; any exception during reading/writing (IOException, closed stream, broken connection) is wrapped in this ActivitiException, with the stream's descriptive name included.
Solutions
- Check the wrapped cause (e.getCause()) to identify the underlying I/O failure.
- Ensure the InputStream is open and not yet fully consumed when passed in.
- Use standard java.io/nio APIs with try-with-resources for custom scenarios instead of re-reading the same stream.
Example fix
// before byte[] data = IoUtil.readInputStream(inputStream, "resource"); byte[] again = IoUtil.readInputStream(inputStream, "resource"); // throws: stream consumed // after byte[] data = IoUtil.readInputStream(inputStream, "resource"); byte[] again = data; // reuse bytes; never re-read a consumed stream
Defensive patterns
Strategy: try-catch
Try / catch
try {
byte[] data = IoUtil.readInputStream(in, name);
} catch (ActivitiException e) {
if (e.getCause() instanceof java.io.IOException) { /* reopen stream or abort */ }
} Prevention
- Never read the same InputStream twice; streams are single-use
- Use try-with-resources and check stream open state before passing it
- For remote streams, apply timeouts and retry with a fresh stream
When it happens
Trigger: Calling IoUtil.readInputStream(inputStream, name) where the stream throws during read(): stream already closed, socket broken mid-read, or errors from a file/network-backed stream.
Common situations: Reading deployment resources from a closed connection; streams consumed twice (second read after the stream is exhausted); timeouts on remote resource streams.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- could not get byte array from resource
- Error converting resource stream
- Error converting resource stream
- Error converting resource stream
- Error converting resource stream
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/0040f9bf2acbfd7e.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/util/IoUtil.java:45
/**
* @author Tom Baeyens
* @author Frederik Heremans
* @author Joram Barrez
*/
public class IoUtil {
public static byte[] readInputStream(InputStream inputStream, String inputStreamName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[16 * 1024];
try {
int bytesRead = inputStream.read(buffer);
while (bytesRead != -1) {
outputStream.write(buffer, 0, bytesRead);
bytesRead = inputStream.read(buffer);
}
} catch (Exception e) {
throw new ActivitiException("couldn't read input stream " + inputStreamName, e);
}
return outputStream.toByteArray();
}
public static String readFileAsString(String filePath) {
byte[] buffer = new byte[(int) getFile(filePath).length()];
BufferedInputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath)));
inputStream.read(buffer);
} catch (Exception e) {
throw new ActivitiException("Couldn't read file " + filePath + ": " + e.getMessage());
} finally {
IoUtil.closeSilently(inputStream);
}
return new String(buffer);
}
View on GitHub (pinned to d6d39ce1c6)