code: static final void cleanup(XMLStreamReader reader) throws XMLStreamException {
      if (reader.nextTag() != END_ELEMENT || !reader.getLocalName().equalsIgnoreCase(SPARQL.name())) {
        logger.warn("Extra data at end of results");
      } else if (reader.next() != END_DOCUMENT) {
        logger.warn("Unexpected data after XML");
      }
      logger.debug("End of input detected, closing reader...");
      reader.close();
    }
docs: Cleans up the stream reader. This method is expected to be called just before the final </sparql>
  end element, which should be the last event in the document. Also closes the stream since
  there's nothing more to read rather than wait for the client to do so.
  @param reader The reader
  @throws XMLStreamException if there was an error accessing the stream.