code: public static KryoPool withByteArrayOutputStream(int poolSize,
        final KryoInstantiator ki) {
      return new KryoPool(poolSize) {
        protected SerDeState newInstance() {
          return new SerDeState(ki.newKryo(), new Input(), new Output(new ByteArrayOutputStream())) {
            /*
             * We have to take extra care of the ByteArrayOutputStream
             */
            @Override
            public void clear() {
              super.clear();
              ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
              byteStream.reset();
            }
            @Override
            public byte[] outputToBytes() {
              output.flush();
              ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
              return byteStream.toByteArray();
            }
            @Override
            public void writeOutputTo(OutputStream os) throws IOException {
              output.flush();
              ByteArrayOutputStream byteStream = (ByteArrayOutputStream)output.getOutputStream();
              byteStream.writeTo(os);
            }
          };
        }
      };
    }
docs: Output is created with new Output(new ByteArrayOutputStream())
  This will automatically resize internally