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