You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/03/02 08:03:35 UTC
[shardingsphere] branch master updated: Avoid ConcurrentHashMap Recursive update (#24416)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 250aa7bf8d2 Avoid ConcurrentHashMap Recursive update (#24416)
250aa7bf8d2 is described below
commit 250aa7bf8d2f41a34e31cebbc106c09d01c658f2
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Thu Mar 2 16:03:26 2023 +0800
Avoid ConcurrentHashMap Recursive update (#24416)
---
.../admin/executor/DefaultSessionVariableHandler.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultSessionVariableHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultSessionVariableHandler.java
index 2f643d93e92..4cd17e3e9fd 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultSessionVariableHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/DefaultSessionVariableHandler.java
@@ -17,28 +17,27 @@
package org.apache.shardingsphere.proxy.backend.handler.admin.executor;
+import lombok.AccessLevel;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import java.util.Collection;
import java.util.Collections;
/**
* Default session variable handler.
*/
@Slf4j
+@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class DefaultSessionVariableHandler implements SessionVariableHandler {
- private final Collection<String> replayedSessionVariables;
-
- protected DefaultSessionVariableHandler(final String databaseType) {
- replayedSessionVariables = TypedSPILoader.findService(ReplayedSessionVariablesProvider.class, databaseType).map(ReplayedSessionVariablesProvider::getVariables).orElse(Collections.emptySet());
- }
+ private final String databaseType;
@Override
public final void handle(final ConnectionSession connectionSession, final String variableName, final String assignValue) {
- if (replayedSessionVariables.contains(variableName)) {
+ if (TypedSPILoader.findService(ReplayedSessionVariablesProvider.class, databaseType).map(ReplayedSessionVariablesProvider::getVariables).orElseGet(Collections::emptySet)
+ .contains(variableName)) {
connectionSession.getRequiredSessionVariableRecorder().setVariable(variableName, assignValue);
} else {
log.debug("Set statement {} = {} was discarded.", variableName, assignValue);