解决nacos异常,发送客户端当只有空格是不推送

This commit is contained in:
wulin 2023-10-21 10:08:24 +08:00
parent ac23efe3a0
commit 62fba7e356
2 changed files with 21 additions and 7 deletions

View File

@ -75,6 +75,12 @@
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
</dependencies>

View File

@ -134,14 +134,18 @@ public class BaseWebSocketProcess {
int m = Math.max(Math.max(Math.max(Math.max(d, j), Math.max(a, b)), c), n);
if (m > 0) {
//清空
sb.setLength(0);
sb.append(old.substring(m));
old = old.substring(0, m);
String msg = old.substring(0, m);
if(msg.replace(" ", "").length() > 0){
//纯空格的不推送
sb.setLength(0);
sb.append(old.substring(m));
normalSendMsg(baseSession, msg, type, YesNo.NO.getCode());
return;
}
normalSendMsg(baseSession, old, type, YesNo.NO.getCode());
} else {
sb.append(message);
}
sb.append(message);
return;
}
@ -152,7 +156,11 @@ public class BaseWebSocketProcess {
@Override
public void finish() {
log.info("千问最后调用finish");
normalSendMsg(baseSession, sb.toString(), type);
String msg = sb.toString();
if(msg.replace(" ", "").length() > 0){
//纯空格的不推送
normalSendMsg(baseSession, sb.toString(), type);
}
MDC.remove(Log4Constans.PRINT_LOG_ID);
}
}).flatMap(data ->{