You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Kevin Deng <de...@gmail.com> on 2007/11/03 03:42:59 UTC

DefaultPreparedCommand log not thread safe

hi all,
 
An exception was thrown by ibatis during my asp.net 2.0 web appliation load
test, finally i found this exception was thrown at DefaultPreparedCommand.cs
line 242

_logger.Debug("Statement Id: [" + statement.Id + "] Parameters: [" +
paramLogList.ToString(0, paramLogList.Length - 2) + "]");

the exception detail as following,

System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32
length, Boolean fAlwaysCopy)
   at System.Text.StringBuilder.ToString (Int32 startIndex, Int32 length)
   at
IBatisNet.DataMapper.Commands.DefaultPreparedCommand.ApplyParameterMap(ISqlMapSession
session, IDbCommand command, RequestScope request, IStatement statement,
Object parameterObject) 
...

Obviously the result of (paramLogList.Length - 2) was less than zero caused
StringBuild.ToString method failed, but it was an impossible fact that
paramLogList.Length was less than 2, so i doubt it is not thread safe, then
I dipped into ibatis.net source and found only one DaoManager instance for
one database, also true for one web application, at least it is true for my
dao configuration, and one DaoManager instance has one _daoSessionHandler
member -> SqlMap -> MappedStatements which contains many MappedStatement
instances -> PreparedCommand, a DefaultPreparedCommand instance, this
instance could be accessed from multiple threads, DefaultPreparedCommand has
2 instance member(2 StringBuilders) _paramLogList and _typeLogList, they
would be shared by multiple threads, so i think it is not thread safe and
caused above exception, right? 
 
I've gooled this issue before i post here, nothing found, so i am not sure
anyone else ran into the same issue before, i work on DataAccess 1.9.1 and
DataMapper 1.6.1.
 
thanks.

-- 
View this message in context: http://www.nabble.com/DefaultPreparedCommand-log-not-thread-safe-tf4741727.html#a13559439
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


Re: DefaultPreparedCommand log not thread safe

Posted by Gilles Bayon <ib...@gmail.com>.
Corrected in SVN


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>