You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2026/04/10 06:21:32 UTC
(shardingsphere) branch master updated: Refactor CommandExecutorTask (#38608)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 3f8dc0165d6 Refactor CommandExecutorTask (#38608)
3f8dc0165d6 is described below
commit 3f8dc0165d66c482b5ad0482d18631423caa4408
Author: jiangML <10...@qq.com>
AuthorDate: Fri Apr 10 14:20:52 2026 +0800
Refactor CommandExecutorTask (#38608)
---
.../frontend/command/CommandExecutorTask.java | 42 ++++++++++++----------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 6fdfd47737b..2efe5b41b8f 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -86,25 +86,7 @@ public final class CommandExecutorTask implements Runnable {
// CHECKSTYLE:ON
processException(new RuntimeException(error));
} finally {
- connectionSession.clearQueryContext();
- Collection<SQLException> exceptions = Collections.emptyList();
- try {
- connectionSession.getDatabaseConnectionManager().closeExecutionResources();
- } catch (final BackendConnectionException ex) {
- exceptions = ex.getExceptions().stream().filter(SQLException.class::isInstance).map(SQLException.class::cast).collect(Collectors.toList());
- }
- if (isNeedFlush) {
- context.flush();
- }
- processClosedExceptions(exceptions);
- context.pipeline().fireUserEventTriggered(new WriteCompleteEvent());
- if (sqlShowEnabled) {
- clearLogMDC();
- }
- if (message instanceof CompositeByteBuf) {
- releaseCompositeByteBuf((CompositeByteBuf) message);
- }
- ((ByteBuf) message).release();
+ finish(isNeedFlush, sqlShowEnabled);
}
}
@@ -151,6 +133,28 @@ public final class CommandExecutorTask implements Runnable {
context.flush();
}
+ private void finish(final boolean isNeedFlush, final boolean sqlShowEnabled) {
+ connectionSession.clearQueryContext();
+ Collection<SQLException> exceptions = Collections.emptyList();
+ try {
+ connectionSession.getDatabaseConnectionManager().closeExecutionResources();
+ } catch (final BackendConnectionException ex) {
+ exceptions = ex.getExceptions().stream().filter(SQLException.class::isInstance).map(SQLException.class::cast).collect(Collectors.toList());
+ }
+ if (isNeedFlush) {
+ context.flush();
+ }
+ processClosedExceptions(exceptions);
+ context.pipeline().fireUserEventTriggered(new WriteCompleteEvent());
+ if (sqlShowEnabled) {
+ clearLogMDC();
+ }
+ if (message instanceof CompositeByteBuf) {
+ releaseCompositeByteBuf((CompositeByteBuf) message);
+ }
+ ((ByteBuf) message).release();
+ }
+
private void processClosedExceptions(final Collection<SQLException> exceptions) {
if (exceptions.isEmpty()) {
return;