[ 
https://issues.apache.org/jira/browse/AMQNET-852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18041180#comment-18041180
 ] 

Theo Harper commented on AMQNET-852:
------------------------------------

Propose fix would be to use:
{code:java}
LastIndexOf(")", StringComparison.Ordinal) 
or
LastIndexOf(")", StringComparison.InvariantCulture){code}

> Culture-sensitive LastIndexOf causes ArgumentOutOfRangeException in Session 
> constructor when thread culture is non-English (.NET 5+)
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AMQNET-852
>                 URL: https://issues.apache.org/jira/browse/AMQNET-852
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: MSMQ
>    Affects Versions: API-2.2.0
>         Environment: Linux / Thai Locale
>            Reporter: Theo Harper
>            Priority: Critical
>
> We are seeing unexpected {{System.ArgumentOutOfRangeException}} errors during 
> construction of {{Apache.NMS.ActiveMQ.Session}} when running under certain 
> non-English cultures. The issue is caused by the use of *culture-sensitive 
> string APIs* inside the library, specifically {{LastIndexOf(")")}} on 
> {{{}brokerUri.Query{}}}, which returns different results under different 
> cultures in .NET 5+ due to ICU globalization changes.
> When the application runs under a non-English culture (e.g., {*}fr-FR{*}, 
> {*}zh-CN{*}, etc.), the following exception occurs:
> System.ArgumentOutOfRangeException: startIndex cannot be larger than length 
> of string. (Parameter 'startIndex')
> This originates from:
> {{brokerUri.Query.LastIndexOf(")")}}
> which returns an unexpected index, causing:
> {color:#000000}Substring(brokerUri.Query.LastIndexOf({color}{color:#000000}")"{color}{color:#000000})
>  + {color}{color:#000000}1{color}{color:#000000}){color}
> to attempt to start beyond the string boundary.
> Under {*}en-US culture{*}, no exception occurs.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to