run() in WorkerThread catches OOM, prints stack trace, calls System.err, calls System.exit(1) #2

Closed
binkley opened this Issue May 11, 2010 · 2 comments

Comments

Projects
None yet
2 participants
@binkley

binkley commented May 11, 2010

I have several issues with WorkerThread.run() which make the code unsuitable for 3rd-party library use (I really appreciate kilim otherwise!) --

  1. Catches OutOfMemoryException - please let my application worry about the sad state of affairs
  2. Prints to STDERR (or STDOUT) - please do not bury console output in the innards of a library, especially not a library built for reuse
  3. Calls System.exit(1) - this turns an exception into a fatality. It is true that OOM is fairly fatal to begin with, but libraries should be about mechanism, not policy
  4. Calls Throwable.printStackTrace() - similar complaint to previous items, console output and policy instead of mechanism

WorkerThread.run():

public void run() {
    try {
        while (true) {
            Task t = getNextTask(this); // blocks until task available
            runningTask = t;
            t._runExecute(this);
            runningTask = null;
        }
    } catch (ShutdownException se) {
        // nothing to do.
    } catch (OutOfMemoryError ex) {
        System.err.println("Out of memory");
        System.exit(1);
    } catch (Throwable ex) {
        ex.printStackTrace();
        System.err.println(runningTask);
    }
    runningTask = null;
}
@binkley

This comment has been minimized.

Show comment Hide comment
@binkley

binkley May 11, 2010

Rereading my issue posting, I do not want to leave the wrong impression - kilim is amazing work, a library I'd like to promote to others. I look forward to your next release!

binkley commented May 11, 2010

Rereading my issue posting, I do not want to leave the wrong impression - kilim is amazing work, a library I'd like to promote to others. I look forward to your next release!

@nqzero

This comment has been minimized.

Show comment Hide comment
@nqzero

nqzero Jan 27, 2018

Collaborator

this is fixed in kilim 2.0 by this commit

by default, log messages are sent to standard error/output (as they always have been) though this may change in the future (i'm wary of making this change since it results in user task errors being silently swallowed)

use Scheduler.getDefaultScheduler().enableExceptionLog = false to disable the log messages. you can also override log() in other Schedulers to use a custom logger

the OOM and exit aspects of this issue have changed previously

Collaborator

nqzero commented Jan 27, 2018

this is fixed in kilim 2.0 by this commit

by default, log messages are sent to standard error/output (as they always have been) though this may change in the future (i'm wary of making this change since it results in user task errors being silently swallowed)

use Scheduler.getDefaultScheduler().enableExceptionLog = false to disable the log messages. you can also override log() in other Schedulers to use a custom logger

the OOM and exit aspects of this issue have changed previously

@nqzero nqzero closed this Jan 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment