- All Implemented Interfaces:
- Closeable, AutoCloseable
public class LoopingByteArrayInputStream
extends InputStream
LoopingByteArrayInputStream.
This was designed specifically to handle the problem in Hadoop's Configuration object that it
tries to read the entire contents of the same InputStream repeatedly without resetting it.
The Configuration object does attempt to close the InputStream though, so, since close does
nothing for the ByteArrayInputStream object, override it to reset it.
It also uses a thread local ByteArrayInputStream for method calls. This is because
Configuration's copy constructor does a shallow copy of the resources, meaning that when the
copy constructor is used to generate HiveConfs in different threads, they all share the same
LoopingByteArrayInputStream. ByteArrayInputStreams are not thread safe in such situations.