BaseXClient.java ignores EOF from server

Monday, 27 September 2010 · 1 message
GB
Godmar Back27 Sep 2010 20:48 #

BaseXClient.receive ignores EOF if the connection is severed:

  /**
   * Receives a string and writes it to the specified output stream.
   * @param o output stream
   * @throws IOException I/O exception
   */
  private void receive(final OutputStream o) throws IOException {
    while(true) {
      final int b = in.read();
      if(b == 0) break;
      o.write(b);
    }
  }

The result is an out of memory error because you're trying to stuff infinitely many -1 values into the ByteArrayOutputStream backing o.

- Godmar


⚡Generated with XQuery