This is an automated email from the ASF dual-hosted git repository.

totalo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new e3d4647  fix for get index of '?' in jdbcUrl (#15842)
e3d4647 is described below

commit e3d4647d3b4b84eebf3be32c96fdc61596d38533
Author: JingShang Lu <[email protected]>
AuthorDate: Mon Mar 7 16:11:27 2022 +0800

    fix for get index of '?' in jdbcUrl (#15842)
---
 .../xa/narayana/config/NarayanaConfigurationFileGenerator.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-x
 [...]
index 8750913..d0222ee 100644
--- 
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
+++ 
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
@@ -165,7 +165,7 @@ public final class NarayanaConfigurationFileGenerator 
implements TransactionConf
             optional -> new DataSourcePoolMetaDataReflection(dataSource.get(), 
optional.getFieldMetaData())).orElseGet(() -> new 
DataSourcePoolMetaDataReflection(dataSource.get()));
         String jdbcUrl = dataSourcePoolMetaDataReflection.getJdbcUrl();
         int endIndex = jdbcUrl.indexOf("?");
-        jdbcUrl = jdbcUrl.substring(0, endIndex);
+        jdbcUrl = -1 == endIndex ? jdbcUrl : jdbcUrl.substring(0, endIndex);
         String username = dataSourcePoolMetaDataReflection.getUsername();
         String password = dataSourcePoolMetaDataReflection.getPassword();
         String dataSourceClassName = getDataSourceClassNameByJdbcUrl(jdbcUrl);

Reply via email to