Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public class StackOverflow {
  public static void main(String[] args) {
    infiniteRun();
    System.out.println("Continuing...");
  }
    
  private static void infiniteRun() {
    try {
      infiniteRun();
    }catch(Throwable t) {
      System.out.println("Handling error...");
      //free cache, release resources and log error to file
    }
  }
}

Note that this solution is an exception to EXC32-J. Do not catch RuntimeException since it catches Throwable in an attempt to handle the error.

Risk Assessment

Allowing a system error to propagate right out of a Java program may result in a denial-of-service attack.

...