Class LookAheadBufferedReader

java.lang.Object
java.io.Reader
java.io.BufferedReader
org.alfresco.solr.client.LookAheadBufferedReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class LookAheadBufferedReader extends BufferedReader
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
The two modes are activated on each instance depending on the level of the 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)
  • Constructor Details

    • LookAheadBufferedReader

      public LookAheadBufferedReader(Reader in, int windowSize, org.slf4j.Logger logger)
    • LookAheadBufferedReader

      public LookAheadBufferedReader(Reader in, org.slf4j.Logger logger)
  • Method Details