@Override
 public int read() throws IOException {
   if (resetPoint == -1) {
     // If I have read nothing yet, remember the reset point in the feed.
     resetPoint = feed.size();
   }
   if (!useAlternate) {
     try {
       return super.read();
     } catch (EmptyDocumentException e) {
       switchToAlternate();
     } catch (BigDocumentException e) {
       LOGGER.finer(
           "Document content exceeds the maximum configured "
               + "document size, discarding content.");
       switchToAlternate();
     }
   }
   return alternate.read();
 }
 // Reset the feed to its position when we started reading this stream,
 // and start reading from the alternate input.
 private void switchToAlternate() {
   if (feed != null) {
     feed.reset(resetPoint);
   }
   useAlternate = true;
 }