This is an automated email from the ASF dual-hosted git repository.
panjuan 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 a6047d8 Refactor usage of ConcurrentHashMap in
DriverExecutionPrepareEngine (#13275)
a6047d8 is described below
commit a6047d89a8447ec4b20897f9440154df413dd63d
Author: 吴伟杰 <[email protected]>
AuthorDate: Tue Oct 26 12:25:44 2021 +0800
Refactor usage of ConcurrentHashMap in DriverExecutionPrepareEngine (#13275)
---
.../prepare/driver/DriverExecutionPrepareEngine.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
index 7bfc41e..d900995 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
@@ -62,7 +62,22 @@ public final class DriverExecutionPrepareEngine<T extends
DriverExecutionUnit<?>
super(maxConnectionsSizePerQuery, rules);
this.executorDriverManager = executorDriverManager;
this.option = option;
- sqlExecutionUnitBuilder = TYPE_TO_BUILDER_MAP.computeIfAbsent(type,
key -> TypedSPIRegistry.getRegisteredService(SQLExecutionUnitBuilder.class,
key, new Properties()));
+ sqlExecutionUnitBuilder = getCachedSqlExecutionUnitBuilder(type);
+ }
+
+ /**
+ * Refer to https://bugs.openjdk.java.net/browse/JDK-8161372.
+ *
+ * @param type type
+ * @return sql execution unit builder
+ */
+ @SuppressWarnings("rawtypes")
+ private SQLExecutionUnitBuilder getCachedSqlExecutionUnitBuilder(final
String type) {
+ SQLExecutionUnitBuilder result;
+ if (null == (result = TYPE_TO_BUILDER_MAP.get(type))) {
+ result = TYPE_TO_BUILDER_MAP.computeIfAbsent(type, key ->
TypedSPIRegistry.getRegisteredService(SQLExecutionUnitBuilder.class, key, new
Properties()));
+ }
+ return result;
}
@Override