diff --git a/src/main/java/com/actiontech/dble/services/BackendService.java b/src/main/java/com/actiontech/dble/services/BackendService.java index 0b01ae843f..c973db8269 100644 --- a/src/main/java/com/actiontech/dble/services/BackendService.java +++ b/src/main/java/com/actiontech/dble/services/BackendService.java @@ -131,7 +131,7 @@ public void execute(ServiceTask task, ThreadContext threadContext) { handleDataError(e); } finally { isHandling.set(false); - if (taskQueue.size() > 0) { + if (!taskQueue.isEmpty()) { doHandle(task); } } @@ -232,7 +232,7 @@ protected void handleInnerData(byte[] data) { protected void handleDataError(Exception e) { LOGGER.warn(this.toString() + " handle data error:", e); connection.close("handle data error:" + e.getMessage()); - while (taskQueue.size() > 0) { + while (!taskQueue.isEmpty()) { clearTaskQueue(); readSize.set(0); // clear all data from the client @@ -697,8 +697,8 @@ public void run() { handleDataError(e); } finally { isHandling.set(false); - if (taskQueue.size() > 0) { - doHandle(null); + if (!taskQueue.isEmpty()) { + doHandle(taskQueue.peek()); } } }