Error handling
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)
-
repo owner -
repo owner -
assigned issue to
-
assigned issue to
-
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.
-
repo owner See if commit
50442a1
solves your problem.
It is a fairly large commit, but changes related to this issue are all in NodeTable
-
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.
-
repo owner I don’t think that is a good idea, fatal() can be called for other reasons too.
-
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); }
-
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.
-
repo owner -
repo owner - changed status to resolved
fixed in 111
- Log in to comment
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.