On Tue, 2010-07-13 at 07:28, Peter Firmstone wrote: > Ok, understood, ANY throwable sounds bad, we should probably pick > something sensible in the Error / Exception hierarchy, that it and below > will log the exception, and anything else above isn't caught, but left > to bubble up the call stack. >
Except that when a Throwable pops out of a Task's run method, the call stack is not relevant. The original thread associated with the task is off doing something else. Is it worth having a notification mechanism so that the TaskManager can notify the Tasks's originator? I'd say if the Task author cares that much about being notified of a Throwable, he/she can write that functionality into the Task. What would you propose to do in case of a "catastrophic" Throwable? System.exit()? Is that up to TaskManager to decide? Again, I'd say if the task author has some reasonable action in mind, let them catch the Throwable and take their action. I wouldn't spend too much time pondering any such additions to TaskManager. It's quite common to just catch a Throwable in case of NullPointerExceptions. If something more disastrous comes along, there's probably not much you can do about it anyway. Cheers, Greg. > Patricia Shanahan wrote: > > On 7/13/2010 1:10 AM, Peter Firmstone wrote: > >> Patricia Shanahan wrote: > >>> I'm getting into writing a new TaskManager, and have a requirements > >>> question. I expect I will have more of them as time goes on. > >>> > >>> TaskManager logs and ignores any Throwable from a Task's run method. > >>> > >>> This troubles me for a couple of reasons. Given the rule that an > >>> interrupt is issued to each Thread during TaskManager termination, I > >>> do not think InterruptedException should be loggable. On the other > >>> hand, should we really be going on running, with just a Level.WARNING > >>> log message, after a really bad JVM problem? > >>> > >>> Patricia > >>> > >> I was thinking about that recently and thought that it should be > >> possible to ask a task it's status. If it has encountered an error, or > >> exception, that could be retrieved, similar to a RunnableFuture. Like > >> you have mentioned, not all exceptions should be caught. Have a look at > >> the comments in JoinManager, there's some interesting comments in there > >> that you might find relevant. If interrupted, it's possible it will be > >> run again. > > > > The Task is a Runnable, and has a Runnable's inherent power to wrap the > > body of its run method in a try-catch. The problem I'm concerned about > > is the handling of disastrous Throwables, such as VirtualMachineError. > > Those are not normally caught, so I would not expect the Task to catch > > them. A warning log message seems an under-reaction. > > > > I've realized we will never get InterruptedException from calling the > > run method, because it is not an Error or a RuntimeException. > > > > Patricia > > -- Greg Trasuk, President StratusCom Manufacturing Systems Inc. - We use information technology to solve business problems on your plant floor. http://stratuscom.com
