[ 
http://issues.apache.org/jira/browse/IBATISNET-67?page=comments#action_65894 ]
     
Ron Grabowski commented on IBATISNET-67:
----------------------------------------

I think this is incorrect too:

 throw new ConfigurationException(
  string.Format("Unable to load config file \"{0}\". Cause : ",
   fileName,
   e.Message ) ,e); 

If you take out just the string.format code, I think you're missing a {1}

 string.Format("Unable to load config file \"{0}\". Cause : ",
  fileName, // 0
  e.Message) // 1

I think the corrected code is:

 throw new ConfigurationException(
  string.Format("Unable to load config file \"{0}\". Cause : {1}",
   fileName,
   e.Message ) ,e); 

Here are the affected functions:

 GetConfigAsXmlDocument(string fileName)
 GetResourceAsXmlDocument(string resource)
 GetUrlAsXmlDocument(string url)
 GetEmbeddedResourceAsXmlDocument(string fileResource) ** 2 times **

In this function at the very bottom of the file:

 SplitFileAndAssemblyNames (string originalFileName) 

"Cause : " should be removed because you aren't passing in {1} with an 
e.Message:

// CORRECT
throw new ConfigurationException(
string.Format("Unable to find assembly part to load embedded resource in string 
\"{0}\".",
originalFileName));

> IBatisNet.Common.Utilities.Resources.GetConfigAsXmlDocument(string) doesn't 
> attempt to close its XmlTextReader when an exception is thrown while parsing 
> the SqlMap.config file
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: IBATISNET-67
>          URL: http://issues.apache.org/jira/browse/IBATISNET-67
>      Project: iBatis for .NET
>         Type: Bug
>     Reporter: Ron Grabowski
>     Assignee: Gilles Bayon

>
> As of 5/20/2005, if an exception is thrown while trying to parse 
> SqlMap.config (note the incorrect closing XML comment tag):
>  <!--
>   <sqlMap embedded="Resources.SqlMaps.Foo.xml, Company.Project.Data"/>
>  ->
> the underlying XmlTextReader is not closed. On XP/IIS, the SqlMap.config file 
> becomes locked by aspnet_wp.exe and the webserver needs to be restarted. This 
> code:
> public static XmlDocument GetConfigAsXmlDocument(string fileName)
> {
>  XmlDocument config = new XmlDocument();
>  try 
>  {
>   XmlTextReader reader = new XmlTextReader(Path.Combine(_baseDirectory, 
> fileName));
>   config.Load(reader);
>   reader.Close(); // <--- NEVER CALLED IF AN EXCEPTION IS THROWN
>  }
>  catch(Exception e)
>  {
>   throw new ConfigurationException(
>    string.Format("Unable to load config file \"{0}\". Cause : ",
>     fileName, 
>    e.Message  ) ,e);
>  }
>  return config;
> }
> Needs to be changed to this:
> public static XmlDocument GetConfigAsXmlDocument(string fileName)
> {
>  XmlDocument config = new XmlDocument();
>  XmlTextReader reader = null;
>  try 
>  {
>   reader = new XmlTextReader(Path.Combine(_baseDirectory, fileName));
>   config.Load(reader);
>  }
>  catch(Exception e)
>  {
>   throw new ConfigurationException(
>    string.Format("Unable to load config file \"{0}\". Cause : ",
>     fileName, 
>    e.Message  ) ,e);
>  }
>  finally
>  {
>   if (reader != null)
>   {
>    reader.Close();
>   }
>  }
>  return config;
> }
> I searched all the files in the Common, DataAccess, and DataMapper projects 
> for "XmlTextReader" and everything else looks correct.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to