totalo commented on a change in pull request #15834:
URL: https://github.com/apache/shardingsphere/pull/15834#discussion_r820301711
##########
File path:
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
##########
@@ -159,19 +158,18 @@ private void
generateUserDefinedJdbcStoreConfiguration(final Properties originTr
private void generateDefaultJdbcStoreConfiguration(final
SchemaConfiguration schemaConfiguration, final Properties props) {
Map<String, DataSource> datasourceMap =
schemaConfiguration.getDataSources();
Optional<DataSource> dataSource =
datasourceMap.values().stream().findFirst();
- if (dataSource.isPresent()) {
- Optional<DataSourcePoolMetaData> poolMetaData =
DataSourcePoolMetaDataFactory.newInstance(dataSource.get().getClass().getName());
- if (poolMetaData.isPresent()) {
- DataSourcePoolMetaDataReflection
dataSourcePoolMetaDataReflection = new
DataSourcePoolMetaDataReflection(dataSource.get());
- String jdbcUrl = dataSourcePoolMetaDataReflection.getJdbcUrl();
- int endIndex = jdbcUrl.indexOf("?");
- jdbcUrl = jdbcUrl.substring(0, endIndex);
- String username =
dataSourcePoolMetaDataReflection.getUsername();
- String password =
dataSourcePoolMetaDataReflection.getPassword();
- String dataSourceClassName =
getDataSourceClassNameByJdbcUrl(jdbcUrl);
- generateTransactionProps(jdbcUrl, username, password,
dataSourceClassName, props);
- }
+ if (!dataSource.isPresent()) {
+ return;
}
+ DataSourcePoolMetaDataReflection dataSourcePoolMetaDataReflection =
DataSourcePoolMetaDataFactory.newInstance(dataSource.get().getClass().getName()).map(
+ 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);
Review comment:
endIndex may be -1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]