Error handling

Issue #7 resolved
Igor Serikov created an issue

Terminating JVM in”resize” (jdd/bdd/NodeTable.java) causes problems in production environment.

Suggestion: the exception should be re-thrown (or not handled at all), so the production application can log a proper message of its own.

Comments (10)

  1. Arash Vahidi (private) repo owner

    I can move the exit code to its own function which you can override if you want a different behavior.

    Note however that the JVM normally terminates after a OutOfMemoryError, hence the error handling code is never reached.

  2. Igor Serikov reporter

    Yes, moving the termination into a function that I can override would work. Just pass the exception to it so I can re-throw it.

    Adding a configuration option preventing termination would work too.

  3. Igor Serikov reporter

    Is it possible to rename “fatal” to outOfMemoryHandler?

    Then all I need to do is:

    @Override
    public void outOfmemoryHandler(String message) {
      throw new OutOfMoeoryError(message);
    }
    

    This way I retain the exception name as well known OutOfMemoryError and use your message to provide an additional information.

  4. Arash Vahidi (private) repo owner

    I don’t think that is a good idea, fatal() can be called for other reasons too.

  5. Igor Serikov reporter

    That is exactly the problem that I am trying to solve. I think, it is better to have an error class. Can we do the following?

    Your code:

    public void outOfmemoryErrorHandler(String message) {
      fatal(message);
    }
    public void fatal(String message) {
    ...
    }
    

    You might call “fatal()” directly for some “uncategorized” errors.

    My Code:

    @Override
    public void outOfmemoryHandler(String message) {
      throw new OutOfMemoryError("JDD: " + message);
    }
    @Override
    public void fatal(String message) {
    // An uncategorized JDD error
      throw new RuntimeException("JDD: " + message);
    }
    
  6. Igor Serikov reporter

    Or, if you think that what I proposed is excessive, just re-define your “fatal” as

    public void fatal(Exception exc, String message)
    

    and supply an exception when appropriate.

    My problem is that OutOfMemoryError is a distinct type of error and needs to be shown as such in the logs.

  7. Log in to comment