You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by Anil Gangolli <an...@busybuddha.org> on 2013/08/10 01:14:46 UTC
Re: svn commit: r1512325 - in /roller/trunk/app/src/main/java/org/apache/roller:
planet/business/jpa/ planet/pojos/ planet/tasks/ planet/util/ weblogger/business/
weblogger/business/jpa/ weblogger/business/runnable/ weblogger/business/startup/
weblogger/bu...
Glen,
We might want to leave the catch Throwable for the two cases below to
avoid the possibility of the corresponding thread dying.
--a.
On 8/9/13 7:42 AM, gmazza@apache.org wrote:
> Author: gmazza
> Date: Fri Aug 9 14:42:46 2013
> New Revision: 1512325
>
> URL:http://svn.apache.org/r1512325
> Log:
> Various Sonar complaints fixed, removed Planet Utilities class in favor of using Roller one throughout.
...
> roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java
> roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/WorkerThread.java
...
Re: svn commit: r1512325 - in /roller/trunk/app/src/main/java/org/apache/roller:
planet/business/jpa/ planet/pojos/ planet/tasks/ planet/util/ weblogger/business/
weblogger/business/jpa/ weblogger/business/runnable/ weblogger/business/startup/
weblogger/bu...
Posted by Glen Mazza <gl...@gmail.com>.
On 08/11/2013 10:16 AM, Anil Gangolli wrote:
>> I just put code similar to this in for TaskScheduler, I'm not sure of
>> the need yet for WorkerThread, as unlike TaskScheduler it's *doing*
>> but not *calling* tasks (and would like to continue even if a single
>> task it calls throws a throwable) and not trapping Throwable allows
>> the Throwable to percolate up to the TaskScheduler, where it can be
>> properly handled.
> A couple of comments: The cleanup in WorkerThread will now be
> skipped in the case of an uncaught Throwable. You can probably fix
> that by moving the cleanup to a finally clause, (where it probably
> should have been in the first place), but more than that, I am not
> sure all of the code that uses WorkerThread is actually ready for
> uncaught Throwables and to restart if the thread is meant to be
> long-lived. One example I notice is that ContinuousWorkerThread,
> which extends WorkerThread, has the problem that it may now not be as
> "continuous" as desired; it seems to have been relying on super.run()
> (i.e. WorkerThread.run()) never throwing anything. Maybe the wrapping
> should be there, but you should also look at other places that
> WorkerThread is used and what happens if it dies.
Done the first part. As for the second, it's used in HitCountQueue and
ReferrerQueueManagerImpl. It seems to be six on one side, half-a-dozen
on the other whether to try to silently continue with java.lang.Errors
(with the understanding that, if unsuccessful, these two queues aren't
going to be working anyway and that nobody's going to know unless
they're reading the log files regularly) vs. having Roller actually halt
on a java.lang.Error (making it clear and obvious that something's wrong
with the setup). I would say let's run it for a few months as-is, find
out what (if any) java.lang.Errors are occurring that we can recover
from and just trap *those* (or fix the code so they won't occur).
Sometimes you want the system to halt during development so you are
immediately aware of a problem, so you can get it fixed.
>
>>
>> BTW, are you sure the two cases in
>> org.apache.roller.weblogger.business.GuiceWebloggerProvider can't
>> rely on Exception instead of Throwable? I kept those two at
>> Throwable per your earlier comment on them but is seems like
>> Exception may be good enough for those.
> Commonly Class.forName can throw both ClassNotFoundException and
> NoClassDefFoundError, and possibly various IOErrors depending on the
> ClassLoader used. So catching Throwable is not uncommon when using
> that. It looks like the current code takes whatever was caught and
> rethrows it wrapped in a RuntimeException. I think in either case
> the webapp will die during initialization, so it probably does not
> matter that much. I'm not sure if the wrapping was done for some
> purpose or not, like inducing better logging from a higher level. Dave
> might know this one.
OK, I'll keep these as-is, except throwing the ThreadDeaths as the
Javadoc advises.
Thanks,
Glen
>>
>> Regards,
>> Glen
>>
>
Re: svn commit: r1512325 - in /roller/trunk/app/src/main/java/org/apache/roller:
planet/business/jpa/ planet/pojos/ planet/tasks/ planet/util/ weblogger/business/
weblogger/business/jpa/ weblogger/business/runnable/ weblogger/business/startup/
weblogger/bu...
Posted by Anil Gangolli <an...@busybuddha.org>.
> I just put code similar to this in for TaskScheduler, I'm not sure of
> the need yet for WorkerThread, as unlike TaskScheduler it's *doing*
> but not *calling* tasks (and would like to continue even if a single
> task it calls throws a throwable) and not trapping Throwable allows
> the Throwable to percolate up to the TaskScheduler, where it can be
> properly handled.
A couple of comments: The cleanup in WorkerThread will now be skipped
in the case of an uncaught Throwable. You can probably fix that by
moving the cleanup to a finally clause, (where it probably should have
been in the first place), but more than that, I am not sure all of the
code that uses WorkerThread is actually ready for uncaught Throwables
and to restart if the thread is meant to be long-lived. One example I
notice is that ContinuousWorkerThread, which extends WorkerThread, has
the problem that it may now not be as "continuous" as desired; it seems
to have been relying on super.run() (i.e. WorkerThread.run()) never
throwing anything. Maybe the wrapping should be there, but you should
also look at other places that WorkerThread is used and what happens if
it dies.
>
> BTW, are you sure the two cases in
> org.apache.roller.weblogger.business.GuiceWebloggerProvider can't rely
> on Exception instead of Throwable? I kept those two at Throwable per
> your earlier comment on them but is seems like Exception may be good
> enough for those.
Commonly Class.forName can throw both ClassNotFoundException and
NoClassDefFoundError, and possibly various IOErrors depending on the
ClassLoader used. So catching Throwable is not uncommon when using
that. It looks like the current code takes whatever was caught and
rethrows it wrapped in a RuntimeException. I think in either case the
webapp will die during initialization, so it probably does not matter
that much. I'm not sure if the wrapping was done for some purpose or
not, like inducing better logging from a higher level. Dave might know
this one.
>
> Regards,
> Glen
>
Re: svn commit: r1512325 - in /roller/trunk/app/src/main/java/org/apache/roller:
planet/business/jpa/ planet/pojos/ planet/tasks/ planet/util/ weblogger/business/
weblogger/business/jpa/ weblogger/business/runnable/ weblogger/business/startup/
weblogger/bu...
Posted by Glen Mazza <gl...@gmail.com>.
Well, for Throwable's ThreadDeath, apparently we do need to throw it so
the thread *will* die:
http://docs.oracle.com/javase/7/docs/api/java/lang/ThreadDeath.html,
http://c2.com/cgi/wiki?JavaExceptionsAreParticularlyEvil) AlexPopiel's
sample in the second link has this code:
try {
someUserClass.run();
} catch (Thread**Death t) {
throw t;
} catch (Throwable t) {
System.err.print("User supplied code failed:");
t.printStackTrace(System.err);
}
I just put code similar to this in for TaskScheduler, I'm not sure of
the need yet for WorkerThread, as unlike TaskScheduler it's *doing* but
not *calling* tasks (and would like to continue even if a single task it
calls throws a throwable) and not trapping Throwable allows the
Throwable to percolate up to the TaskScheduler, where it can be properly
handled.
BTW, are you sure the two cases in
org.apache.roller.weblogger.business.GuiceWebloggerProvider can't rely
on Exception instead of Throwable? I kept those two at Throwable per
your earlier comment on them but is seems like Exception may be good
enough for those.
Regards,
Glen
On 08/09/2013 07:14 PM, Anil Gangolli wrote:
>
> Glen,
>
> We might want to leave the catch Throwable for the two cases below to
> avoid the possibility of the corresponding thread dying.
>
> --a.
>
>
>
> On 8/9/13 7:42 AM, gmazza@apache.org wrote:
>> Author: gmazza
>> Date: Fri Aug 9 14:42:46 2013
>> New Revision: 1512325
>>
>> URL:http://svn.apache.org/r1512325
>> Log:
>> Various Sonar complaints fixed, removed Planet Utilities class in
>> favor of using Roller one throughout.
> ...
>> roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java
>> roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/WorkerThread.java
> ...
>