commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolás Meléndez <nmelen...@socialmetrix.com>
Subject [Common Configuration] Bad Exception Handling in ConfigurationFactory
Date Tue, 14 Sep 2010 14:48:03 GMT
Hi there, i was looking code at ConfigurationFactory and maybe a find
a problem, what do you think?

in class ConfigurationFactory, line 184:

if digester.parse(input); throws an exception,  the input stream
doesn't close, and a process will leak of resources.

i think there should be a finally which closes the stream no matter
what happen to the parsing, maybe something like this:

 try{
            digester.parse(input);
        }
        catch (SAXException saxe)
        {
            log.error("SAX Exception caught", saxe);
            throw new ConfigurationException("SAX Exception caught", saxe);
        }
 finally {

	try {
            input.close();
	} catch (IOException ioe)
        {
            log.error("IO Exception caught", ioe);
            throw new ConfigurationException("IO Exception caught", ioe);
        }

     }

        return builder.getConfiguration();


What people think here, i am right?

Nicolas Melendez

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message