docs: public DiagnosedStreamCorruptionException analyzeCrash(Exception problem, String diagnosisName) {
          final ByteArrayOutputStream readAhead = new ByteArrayOutputStream();
          final IOException[] error = new IOException[1];
  
          Thread diagnosisThread = new Thread(diagnosisName+" stream corruption diagnosis thread") {
              public void run() {
                  int b;
                  try {
                      // not all InputStream will look for the thread interrupt flag, so check that explicitly to be defensive
                      while (!Thread.interrupted() && (b=source.read())!=-1) {
                          readAhead.write(b);
                      }
                  } catch (IOException e) {
                      error[0] = e;
                  }
              }
          };
  
          // wait up to 1 sec to grab as much data as possible
          diagnosisThread.start();
          try {
              diagnosisThread.join(1000);
          } catch (InterruptedException ignored) {
              // we are only waiting for a fixed amount of time, so we'll pretend like we were in a busy loop
              Thread.currentThread().interrupt();
              // fall through
          }
  
          IOException diagnosisProblem = error[0]; // capture the error, if any, before we kill the thread
          if (diagnosisThread.isAlive())
              diagnosisThread.interrupt();    // if it's not dead, kill
  
          return new DiagnosedStreamCorruptionException(problem,diagnosisProblem,getRecord(),readAhead.toByteArray());
  
      }