tds/src/main/java/thredds/server/TdsErrorHandling.java
@ExceptionHandler(Throwable.class)
  public ResponseEntity<String> handle(Throwable ex) throws Throwable {
    // If the exception is annotated with @ResponseStatus rethrow it and let
    // the framework handle it - like the OrderNotFoundException example
    // at the start of this post.
    // AnnotationUtils is a Spring Framework utility class.
    // see https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc
    if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null)
      throw ex;

    logger.error("uncaught exception", ex);
    // ex.printStackTrace(); // temporary - remove in production

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_PLAIN);
    String msg = ex.getMessage();
      StringWriter sw = new StringWriter();
      PrintWriter p = new PrintWriter(sw);
      ex.printStackTrace(p);
      p.close();
      sw.close();
      msg = sw.toString();
    return new ResponseEntity<>("Throwable exception handled : " + htmlEscape(msg), responseHeaders, HttpStatus.INTERNAL_SERVER_ERROR);
  }
@ExceptionHandler(Throwable.class)
  public ResponseEntity<String> handle(Throwable ex) throws Throwable {
    // If the exception is annotated with @ResponseStatus rethrow it and let
    // the framework handle it - like the OrderNotFoundException example
    // at the start of this post.
    // AnnotationUtils is a Spring Framework utility class.
    // see https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc
    if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null)
      throw ex;

    logger.error("uncaught exception", ex);
    // ex.printStackTrace(); // temporary - remove in production

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_PLAIN);
    String msg = ex.getMessage();
      StringWriter sw = new StringWriter();
      PrintWriter p = new PrintWriter(sw);
      ex.printStackTrace(p);
      p.close();
      sw.close();
      msg = sw.toString();
    return new ResponseEntity<>("Throwable exception handled : " + htmlEscape(msg), responseHeaders, HttpStatus.INTERNAL_SERVER_ERROR);
  }
@ ExceptionHandler ( Throwable . class ) public ResponseEntity < String > handle ( Throwable ex ) throws Throwable { // If the exception is annotated with @ResponseStatus rethrow it and let // the framework handle it - like the OrderNotFoundException example // at the start of this post. // AnnotationUtils is a Spring Framework utility class. // see https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc if ( AnnotationUtils . findAnnotation ( ex . getClass ( ) , ResponseStatus . class ) != null ) throw ex ; logger . error ( "uncaught exception" , ex ) ; // ex.printStackTrace(); // temporary - remove in production HttpHeaders responseHeaders = new HttpHeaders ( ) ; responseHeaders . setContentType ( MediaType . TEXT_PLAIN ) ; String msg = ex . getMessage ( ) ; StringWriter sw = new StringWriter ( ) ; PrintWriter p = new PrintWriter ( sw ) ; ex . printStackTrace ( p ) ; p . close ( ) ; sw . close ( ) ; msg = sw . toString ( ) ; return new ResponseEntity <> ( "Throwable exception handled : " + htmlEscape ( msg ) , responseHeaders , HttpStatus . INTERNAL_SERVER_ERROR ) ; }
LOOK this could be a problem
LOOK this could be a problem