|
From: David G. <dg...@co...> - 2003-08-06 04:25:52
|
Creating and deleting the variables won't help with the scheduler variable,
which is needed in finishUp() to stop all running worker threads. Currently,
Scanner.finshUp() crashes as follows:
java.lang.NullPointerException
at com.babeldoc.scanner.ScannerWorkerScheduler.stopAll(Unknown Source)
at com.babeldoc.scanner.Scanner.stop(Unknown Source)
at com.babeldoc.scanner.Scanner.finishUp(Unknown Source)
at com.babeldoc.core.BabeldocCommand$1$ShutMeDownNicely.run(Unknown
Source)
because the scheduler variable is instantiated in execute() (actually, it's
instantiated in start(), which is invoked by execute()), but then it's
reinitialized to null by the time finishUp() tries to use it to shut down
things.
I'm not quite sure how best to address this problem. One way that immediately
comes to mind is to change the calling method so that execute() is invoked
separately from the constructor, but that will probably involve changing code
in each tool. It can be fixed just in Scanner, but then it will probably
come back to bite another developer (or the same, forgetful one) somewhere in
the distant future...
David
On Tuesday 05 August 2003 8:45 pm, Bruce McDonald wrote:
> This pattern is used for all commandline tools.
>
> I guess that most variables that are needed should be encapsulated in a
> class that is created and deleted within execute.
>
> regards,
> Bruce.
>
> On Tuesday 05 August 2003 11:45 pm, David Glick wrote:
> > I noticed that the constructor for Scanner looks like (or, actually, IS):
> >
> > public Scanner(String[] args) {
> > super("scanner", I18n.get("scanner.Scanner.toolDescription"), args);
> > }
> >
> > which I believe causes the parent BabelDocCommand class constructor to
> > initialize the command line properly and then invoke execute() on
> > Scanner. What seems to be happening, though, is that, should any private
> > variables be initialized at declaration (private boolean test = false;),
> > and then set to true in execute(), it will be false again in finishUp().
> > Apparently, not all variables are initialized at the time that the
> > constructor is called, and so the variables are initialized sometime
> > after execute() is executing...
> >
> > This caused me some intersting moments in trying to have the Scanner
> > class end elegantly after displaying the help screen. I assume that all
> > the other tools use the same architecture. Is this a known side effect?
> >
> >
> > David
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
--
David Glick
Transmit Consulting, Inc
619-475-4052
dg...@tr...
|