code: byte[] readAndClose(InputStream input) throws IOException {
          byte[] buffer = new byte[512];
          ByteArrayOutputStream out = new ByteArrayOutputStream(buffer.length);
          int read;
          try {
              read = input.read(buffer); //assignment separate from loop invariant check for code coverage checks
              while (read != -1) {
                  out.write(buffer, 0, read);
                  read = input.read(buffer);
              }
          } finally {
              Objects.nullSafeClose(input);
          }
          return out.toByteArray();
      }
docs: TODO: make protected on a minor release