classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] FYI: Made PixelGrabber more robust


From: Jeroen Frijters
Subject: RE: [cp-patches] FYI: Made PixelGrabber more robust
Date: Fri, 19 Aug 2005 11:35:54 +0200

Mark Wielaard wrote:
> Sent: Thursday, August 18, 2005 22:57
> To: Roman Kennke
> Cc: Classpath-Patches
> Subject: Re: [cp-patches] FYI: Made PixelGrabber more robust
> 
> Hi,
> 
> On Thu, 2005-08-18 at 15:41 +0200, Roman Kennke wrote:
> >             public void run ()
> >             {
> > -             ip.startProduction (PixelGrabber.this);
> > +              try
> > +                {
> > +                  ip.startProduction (PixelGrabber.this);
> > +                }
> > +              catch (Exception ex)
> > +                {
> > +                  ex.printStackTrace();
> > +                  imageComplete(ImageConsumer.ABORTED);
> > +                }
> >             }
> >           };
> 
> Why catch Exception and not Throwable? (You will miss notifying the
> consumer when an Error is thrown). Why print the stack trace?

IMO, the proper way to handle this is a pattern like this:

boolean ok = false;
try
  {
    ip.startProduction(PixelGrabber.this);
    ok = true;
  }
finally
  {
    if (!ok)
      imageComplete(ImageConsumer.ABORTED);
  }

That way you never swallow the exception (so that it can bubble up to
the unhandled exception handler for the thread/threadgroup.

Regards,
Jeroen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]