Am 14.09.2010 16:48, schrieb Nicolás Meléndez:
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

This sounds reasonable and should probably be changed.

However, the ConfigurationFactory class is a bit outdated. It is fully replaced by DefaultConfigurationBuilder. New applications should use this new class. It provides a super set of the features of ConfigurationFactory.

Oliver

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

Reply via email to