Search code examples
javavert.xvertx3

vertx.io vertical stop working on exception


Working with vertx.io 3.0.0, when an exception is thrown and not catch in the JAVA API the vertical freezes. We are working on a single server environment, the server is not in a cluster.

Any thoughts?


Solution

  • You should catch the current thread's unhanded exception using:

    Thread.currentThread().setUncaughtExceptionHandler(
         new Thread.UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
         LOGGER.error(t + " throws exception: " + e);
      }
    });
    

    If you are using multiple vertical, I would recommend that you add UncaughtExceptionhandler for each vertical, as each vertical will have its own event loop and hence, its own thread.

    There is a similar question for java already answered: Java uncaught global exception handler