Package org.alfresco.solr.client
Class LookAheadBufferedReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
org.alfresco.solr.client.LookAheadBufferedReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
This is an enhanced
BufferedReader
used for transparently collect data from the incoming stream before
it gets consumed by the usual buffered reader logic. The data is not actually consumed, it is just buffered beside and
it can be printed in case we want to debug the underlying stream content.
The name refers to the usage pattern: this reader is used for wrapping a character stream coming from a remote call and, in case
of issues, it collects the remaining (i.e. unread) part of the stream so it will be available for debugging purposes.
It provides two different collecting modes:
- windowing: the collected data is a window of the original stream (about 500 chars), and the character that caused a stop in the reading is more or less in the middle of that window.
- everything: the collected data is the whole character stream
Logger
passed in input.
Specifically:
- DEBUG: enables the windowing mode
- TRACE: enables the "collect everything" mode
- other levels simply disables the buffering behaviour (i.e. nothing is collected)
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionLookAheadBufferedReader
(Reader in, int windowSize, org.slf4j.Logger logger) LookAheadBufferedReader
(Reader in, org.slf4j.Logger logger) -
Method Summary
Methods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, readLine, ready, reset, skip
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
Constructor Details
-
LookAheadBufferedReader
-
LookAheadBufferedReader
-
-
Method Details
-
read
- Overrides:
read
in classBufferedReader
- Throws:
IOException
-
lookAheadAndGetBufferedContent
-