I was trying to analyse a recently-found issue in my application and realized that my inputStream.reset()
method fails because I was trying to operate on FileInputStream
.
It seems that my method call For apache's DiskFile.getInputStram()
returns ByteArrayInputStream
instance (mark supported) or FileInputStream
(mark NOT supported) instance based on certain file size threshold.
The code I have to get this inputstream is:
FormFile file = multipartForm.getFiles().get(0); // It's always one file
InputStream is = file.getInputStream();
// Read the stream and did job
// Now I want to reset it.
// bad coding from my side because I didn't check markSupported
is.reset();
// Got IO error immediately after this. But anything below 256KB is ok
I am sure this is mentioned/explained somewhere in Oracle JDK docs or apache's site. but cannot seem to remember any references. Does anyone know if this behaviour makes sense?