private String stackTraceStr(final Throwable error){
  if (error == null) {
    return "";
  }
  StringWriter sw=new StringWriter();
  PrintWriter pw=new PrintWriter(sw);
  error.printStackTrace(pw);
  pw.close();
  return sw.toString();
}

private String stackTraceStr ( final Throwable error ) { if ( error == null ) { return "" ; } StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; error . printStackTrace ( pw ) ; pw . close ( ) ; return sw . toString ( ) ; }
grab the stack trace into a string since the exception was thrown in a thread and we want the assert outside the thread to show the stack trace in case of failure .
