Thanks Andrew and Alexey. I tried writing a test case for the SecurityException as Andrew described and the RI does not throw an Exception, so it's definitely right that we should catch the SecurityException. I'm still unsure about the IOException, especially as the signature of the method states that an IOException is thrown, but if it can't be tested then it's probably best to leave it.
Sian On 09/01/07, Alexey Petrenko <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>: > 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 > >
-- Sian January IBM Java Technology Centre, UK
