diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 405244af13b10..c05a3bc8fb1c8 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -56,6 +56,7 @@
1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) Support SQL like `SELECT id, COUNT(*) FROM table GROUP BY 1,2`
1. [ISSUE #1120](https://github.com/sharding-sphere/sharding-sphere/issues/1120) Derived columns of `GROUP BY / ORDER BY` appear in query result
1. [ISSUE #1186](https://github.com/sharding-sphere/sharding-sphere/issues/1186) Dead lock may occur on MEMORY_STRICTLY mode when get connection on concurrency environment
+1. [ISSUE #1265](https://github.com/sharding-sphere/sharding-sphere/issues/1265) RoundRobinMasterSlaveLoadBalanceAlgorithm throw an ArrayIndexOutOfBoundsException when AtomicInteger overflow
#### Sharding-JDBC
diff --git a/RELEASE-NOTES_ZH.md b/RELEASE-NOTES_ZH.md
index b5e6653799a07..e5757b80ded1c 100644
--- a/RELEASE-NOTES_ZH.md
+++ b/RELEASE-NOTES_ZH.md
@@ -58,6 +58,7 @@
1. [ISSUE #1015](https://github.com/sharding-sphere/sharding-sphere/issues/1015) 支持SQL `SELECT id, COUNT(*) FROM table GROUP BY 1,2`
1. [ISSUE #1120](https://github.com/sharding-sphere/sharding-sphere/issues/1120) `GROUP BY / ORDER BY`产生的补列不应展现在查询结果中
1. [ISSUE #1186](https://github.com/sharding-sphere/sharding-sphere/issues/1186) 在MEMORY_STRICTLY模式中,并发环境下可能产生死锁
+1. [ISSUE #1265](https://github.com/sharding-sphere/sharding-sphere/issues/1265) 当AtomicInteger溢出后,RoundRobinMasterSlaveLoadBalanceAlgorithm抛出ArrayIndexOutOfBoundsException异常
#### Sharding-JDBC
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/api/algorithm/masterslave/RoundRobinMasterSlaveLoadBalanceAlgorithm.java b/sharding-core/src/main/java/io/shardingsphere/core/api/algorithm/masterslave/RoundRobinMasterSlaveLoadBalanceAlgorithm.java
index 955c8c71b0316..fe7effb48b009 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/api/algorithm/masterslave/RoundRobinMasterSlaveLoadBalanceAlgorithm.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/api/algorithm/masterslave/RoundRobinMasterSlaveLoadBalanceAlgorithm.java
@@ -35,6 +35,6 @@ public String getDataSource(final String name, final String masterDataSourceName
AtomicInteger count = COUNT_MAP.containsKey(name) ? COUNT_MAP.get(name) : new AtomicInteger(0);
COUNT_MAP.putIfAbsent(name, count);
count.compareAndSet(slaveDataSourceNames.size(), 0);
- return slaveDataSourceNames.get(count.getAndIncrement() % slaveDataSourceNames.size());
+ return slaveDataSourceNames.get(Math.abs(count.getAndIncrement()) % slaveDataSourceNames.size());
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
index b229acac25464..deea9210a6fb5 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/ShardingExecuteEngine.java
@@ -24,7 +24,6 @@
import io.shardingsphere.core.exception.ShardingException;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -53,72 +52,6 @@ public ShardingExecuteEngine(final int executorSize) {
MoreExecutors.addDelayedShutdownHook(executorService, 60, TimeUnit.SECONDS);
}
- /**
- * Execute.
- *
- * @param inputs input values
- * @param callback sharding execute callback
- * @param type of input value
- * @param type of return value
- * @return execute result
- * @throws SQLException throw if execute failure
- */
- public List execute(final Collection inputs, final ShardingExecuteCallback callback) throws SQLException {
- return execute(inputs, null, callback);
- }
-
- /**
- * Execute.
- *
- * @param inputs input values
- * @param firstCallback first sharding execute callback
- * @param callback sharding execute callback
- * @param type of input value
- * @param type of return value
- * @return execute result
- * @throws SQLException throw if execute failure
- */
- public List execute(final Collection inputs, final ShardingExecuteCallback firstCallback, final ShardingExecuteCallback callback) throws SQLException {
- if (inputs.isEmpty()) {
- return Collections.emptyList();
- }
- Iterator inputIterator = inputs.iterator();
- I firstInput = inputIterator.next();
- Collection> restFutures = asyncExecute(Lists.newArrayList(inputIterator), callback);
- return getResults(syncExecute(firstInput, null == firstCallback ? callback : firstCallback), restFutures);
- }
-
- private Collection> asyncExecute(final Collection inputs, final ShardingExecuteCallback callback) {
- Collection> result = new ArrayList<>(inputs.size());
- for (final I each : inputs) {
- result.add(executorService.submit(new Callable() {
-
- @Override
- public O call() throws SQLException {
- return callback.execute(each);
- }
- }));
- }
- return result;
- }
-
- private O syncExecute(final I input, final ShardingExecuteCallback callback) throws SQLException {
- return callback.execute(input);
- }
-
- private List getResults(final O firstResult, final Collection> restFutures) throws SQLException {
- List result = new LinkedList<>();
- result.add(firstResult);
- for (ListenableFuture each : restFutures) {
- try {
- result.add(each.get());
- } catch (final InterruptedException | ExecutionException ex) {
- return throwException(ex);
- }
- }
- return result;
- }
-
/**
* Execute for group.
*
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
index 8c930ea6a6a78..fe7fe4282fe8a 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/executor/sql/execute/SQLExecuteTemplate.java
@@ -41,42 +41,6 @@ public final class SQLExecuteTemplate {
private final ShardingExecuteEngine executeEngine;
- /**
- * Execute.
- *
- * @param statementExecuteUnits SQL execute units
- * @param callback SQL execute callback
- * @param class type of return value
- * @return execute result
- * @throws SQLException SQL exception
- */
- public List execute(final Collection extends StatementExecuteUnit> statementExecuteUnits, final SQLExecuteCallback callback) throws SQLException {
- return execute(statementExecuteUnits, null, callback);
- }
-
- /**
- * Execute.
- *
- * @param statementExecuteUnits SQL execute units
- * @param firstExecuteCallback first SQL execute callback
- * @param callback SQL execute callback
- * @param class type of return value
- * @return execute result
- * @throws SQLException SQL exception
- */
- @SuppressWarnings("unchecked")
- public List execute(
- final Collection extends StatementExecuteUnit> statementExecuteUnits, final SQLExecuteCallback firstExecuteCallback, final SQLExecuteCallback callback) throws SQLException {
- try {
- return executeEngine.execute((Collection) statementExecuteUnits, firstExecuteCallback, callback);
- } catch (final SQLException ex) {
- ExecutorExceptionHandler.handleException(ex);
- return Collections.emptyList();
- }
- }
-
-
-
/**
* Execute group.
*
@@ -111,4 +75,3 @@ public List executeGroup(final Collection
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package io.shardingsphere.core.parsing.parser.sql;
-
-import io.shardingsphere.core.constant.DatabaseType;
-import io.shardingsphere.core.parsing.SQLParsingEngine;
-import io.shardingsphere.core.parsing.parser.sql.dml.DMLStatement;
-import io.shardingsphere.core.rule.ShardingRule;
-import org.junit.Test;
-
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public final class UpdateStatementParserTest extends AbstractStatementParserTest {
-
- @Test
- public void parseWithOr() {
- ShardingRule shardingRule = createShardingRule();
- DMLStatement updateStatement = (DMLStatement) new SQLParsingEngine(
- DatabaseType.Oracle, "UPDATE TABLE_XXX AS xxx SET field1=1 WHERE field1<1 AND (field1 >2 OR xxx.field2 =1)", shardingRule, null).parse(false);
- assertUpdateStatementWitOr(updateStatement);
- }
-
- private void assertUpdateStatementWitOr(final DMLStatement updateStatement) {
- assertThat(updateStatement.getTables().find("TABLE_XXX").get().getName(), is("TABLE_XXX"));
- assertThat(updateStatement.getTables().find("TABLE_XXX").get().getAlias().get(), is("xxx"));
- assertTrue(updateStatement.getConditions().getOrCondition().getAndConditions().isEmpty());
-
- }
-}
diff --git a/sharding-core/src/test/resources/parser/update.xml b/sharding-core/src/test/resources/parser/update.xml
index 041fce44f2e17..2d354f7c0ca05 100644
--- a/sharding-core/src/test/resources/parser/update.xml
+++ b/sharding-core/src/test/resources/parser/update.xml
@@ -142,4 +142,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/AbstractStatementExecutor.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/AbstractStatementExecutor.java
index 5cdbc6170331f..f8dfba0bf6592 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/AbstractStatementExecutor.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/executor/AbstractStatementExecutor.java
@@ -74,7 +74,7 @@ public class AbstractStatementExecutor {
private final Collection> executeGroups = new LinkedList<>();
- @Getter
+ @Getter(AccessLevel.PROTECTED)
@Setter
private SQLType sqlType;
diff --git a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
index c7a41a1f0dce2..338cb3df43cfa 100644
--- a/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
+++ b/sharding-jdbc/src/main/java/io/shardingsphere/core/jdbc/adapter/AbstractConnectionAdapter.java
@@ -118,7 +118,7 @@ public final List getConnections(final String dataSourceName, final
}
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
- private synchronized List createConnections(final DataSource dataSource, final int connectionSize) throws SQLException {
+ private List createConnections(final DataSource dataSource, final int connectionSize) throws SQLException {
List result = new ArrayList<>(connectionSize);
synchronized (dataSource) {
for (int i = 0; i < connectionSize; i++) {
diff --git a/sharding-jdbc/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml b/sharding-jdbc/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
index 5ca3081fcde8c..f03cacf9c497d 100644
--- a/sharding-jdbc/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
+++ b/sharding-jdbc/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml
@@ -113,6 +113,10 @@
+
+
+
+
diff --git a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/ExecuteEventListenerTest.java b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/ExecuteEventListenerTest.java
index c4964bbe12e2a..606d92817e290 100644
--- a/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/ExecuteEventListenerTest.java
+++ b/sharding-opentracing/src/test/java/io/shardingsphere/opentracing/listener/ExecuteEventListenerTest.java
@@ -21,6 +21,7 @@
import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.core.constant.SQLType;
import io.shardingsphere.core.executor.ShardingExecuteEngine;
+import io.shardingsphere.core.executor.ShardingExecuteGroup;
import io.shardingsphere.core.executor.StatementExecuteUnit;
import io.shardingsphere.core.executor.sql.execute.SQLExecuteCallback;
import io.shardingsphere.core.executor.sql.execute.SQLExecuteTemplate;
@@ -36,6 +37,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -73,8 +75,9 @@ protected Integer executeSQL(final StatementExecuteUnit statementExecuteUnit) {
return 0;
}
};
- sqlExecuteTemplate.execute(Collections.singleton(new StatementExecuteUnit(new RouteUnit("ds_0",
- new SQLUnit("insert into ...", Collections.singletonList(Collections.