harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Petrenko" <alexey.a.petre...@gmail.com>
Subject Re: [classlib] [luni] Ignored Exceptions and HARMONY-2939
Date Wed, 10 Jan 2007 08:32:13 GMT
2007/1/9, Tony Wu <wuyuehao@gmail.com>:
> Does it make sense?
> I think the code below does nothing...
>
> try {
> sm.checkPermission(url.openConnection().getPermission());
> } catch (SecurityException e) {
> }
>
> If access is not permitted based on the current security policy, then
> it will throw a SecurityException. So if you want to ignore the
> exception, why to call the checkPermission?
The original piece of code is
try {
    sm.checkPermission(url.openConnection().getPermission());
    reduced.addElement(url);
} catch (IOException e) {
} catch (SecurityException e) {
}

So the url is added to reduced list only if connection has opened OK
and security checks has passed.

SY, Alexey

>
> On 1/9/07, Alexey Petrenko <alexey.a.petrenko@gmail.com> wrote:
> > Sian,
> >
> > the logic looks OK for me in this method. SecurityException shows that
> > testing url should not be added to reduced list in this case.
> >
> > SY, Alexey
> >
> > 2007/1/8, Sian January <sianjanuary@googlemail.com>:
> > > Hello everyone,
> > >
> > > I have recently been looking at ignored Exceptions in luni (i.e. places
> > > where an Exception is caught but the catch block is empty).  These are
> > > generally a bad idea because if an Exception does occur it is lost - the
> > > user doesn't see it and it's not logged anywhere either, so if it causes a
> > > problem in the program it is very difficult to find the root cause.
> > >
> > > I would like to discuss one of these in particular, in
> > > URLCLassLoader.findResources where an IOException and a
> > > SecurityException are ignored.  Since the signature of the method says that
> > > it throws an IOException (and SecurityException is a subtype of
> > > RuntimeException) I thought the try-catch block could probably be removed
> > > entirely.  However it is an API method and I am finding it difficult to
> > > write a test case for this because I'm not sure how to force either of those
> > > Exceptions.
> > >
> > > Geir suggested it might be an interesting topic for the mailing list so
> > > please post your thoughts.  Also if anyone knows how to write the test case
> > > that would be especially helpful.  Details at
> > > https://issues.apache.org/jira/browse/HARMONY-2939.
> > >
> > > Thanks,
> > >
> > > Sian
> > >
> > > --
> > > Sian January
> > >
> > > IBM Java Technology Centre, UK
> > >
> > >
> >
>
>
> --
> Tony Wu
> China Software Development Lab, IBM
>

Mime
View raw message