UIMA
  1. UIMA
  2. UIMA-2358

UIMA AS should add a global UncaughtExceptionHandler

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.0AS
    • Component/s: Async Scaleout
    • Labels:
      None

      Description

      Currently UIMA AS process doesnt handle uncaught exceptions. Specifically, it should catch OOM Error and exit the process. When the OOM happens now, the jvm dumps an error (stack trace) and the UIMA AS process just hangs. Since JDK 1.5, java supports per thread as well a system wide (for all threads) custom UncaughtExceptionHandler. The application implements this interface and injects the handler to a specific thread via:

      Thread.currentThread().setUncaughtExceptionHandler(new MyExceptionHandler());

      Alternatively, one can set a global error handler via:

      Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler());

      The latter is the approach that I will implement. When OOM Error happens (and perhaps for all errors), the UIMA AS process should exit. For all other exceptions (not caught in a executing thread), the custom exception handler will simply log the exception at WARNING level.

        Activity

        Hide
        Jerry Cwiklik added a comment -

        After further code review it turns out that UIMA AS does catch Throwable in PrimitiveAnalysisEngineController_impl.process() and JmsInputChannel.onMessage(). If OOM happens while a thread is executing in either of these methods, the UIMA AS catches the error. Added additional code to examine a Throwable instance and if it is of type Error, both of these methods dump a stack trace with a message, and subsequently call System.exit(2). Also, added custom global DefaultUncaughtExceptionHandler in case OOM happens somewhere where it is not caught. OOM can happen in any of the jvm threads, and not necessarily in one where the memory leak happens. In such a case,the custom handler will also dump a stack trace with a message and exit the jvm with System.exit(2).

        Show
        Jerry Cwiklik added a comment - After further code review it turns out that UIMA AS does catch Throwable in PrimitiveAnalysisEngineController_impl.process() and JmsInputChannel.onMessage(). If OOM happens while a thread is executing in either of these methods, the UIMA AS catches the error. Added additional code to examine a Throwable instance and if it is of type Error, both of these methods dump a stack trace with a message, and subsequently call System.exit(2). Also, added custom global DefaultUncaughtExceptionHandler in case OOM happens somewhere where it is not caught. OOM can happen in any of the jvm threads, and not necessarily in one where the memory leak happens. In such a case,the custom handler will also dump a stack trace with a message and exit the jvm with System.exit(2).

          People

          • Assignee:
            Jerry Cwiklik
            Reporter:
            Jerry Cwiklik
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development