Skip to content

Commit

Permalink
修复一些idea给出的建议问题
Browse files Browse the repository at this point in the history
  • Loading branch information
codingmiao committed Nov 12, 2024
1 parent 6bd1629 commit 201f478
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public List<SendAbleSessionBytes> fetchBytes(long maxReturnBodySize) {
break;
}
bytesList.add(next);
currentReturnBodySize += next.sessionBytes.getBytes().length;
currentReturnBodySize += next.sessionBytes().getBytes().length;
}
}
return merge(bytesList);
Expand All @@ -128,14 +128,14 @@ public List<SendAbleSessionBytes> fetchBytesBlocked(long maxReturnBodySize) {
return merge(bytesList);
} else {
//根据maxReturnBodySize的限制取出队列中的数据返回
long currentReturnBodySize = first.sessionBytes.getBytes().length;
long currentReturnBodySize = first.sessionBytes().getBytes().length;
while (currentReturnBodySize < maxReturnBodySize) {
SendAbleSessionBytes next = sessionBytesQueue.poll();
if (null == next) {
break;
}
bytesList.add(next);
currentReturnBodySize += next.sessionBytes.getBytes().length;
currentReturnBodySize += next.sessionBytes().getBytes().length;
}
return merge(bytesList);
}
Expand All @@ -150,9 +150,9 @@ private static final class MergeCell {
private static List<SendAbleSessionBytes> merge(List<SendAbleSessionBytes> bytesList) {
Map<Integer, MergeCell> bytesMap = new HashMap<>();
for (SendAbleSessionBytes ssb : bytesList) {
MergeCell mergeCell = bytesMap.computeIfAbsent(ssb.sessionBytes.getSessionId(), (r) -> new MergeCell());
mergeCell.bytesList.add(ssb.sessionBytes.getBytes());
mergeCell.callBacks.add(ssb.callBack);
MergeCell mergeCell = bytesMap.computeIfAbsent(ssb.sessionBytes().getSessionId(), (r) -> new MergeCell());
mergeCell.bytesList.add(ssb.sessionBytes().getBytes());
mergeCell.callBacks.add(ssb.callBack());
}
List<SendAbleSessionBytes> res = new ArrayList<>(bytesMap.size());
bytesMap.forEach((sessionId, mergeCell) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public static void replyToClient(CommonConfig config, ServerSessionManager serve
if (null != fetchBytes && !fetchBytes.isEmpty()) {
if (DebugConfig.OpenSerialNumber) {
for (SendAbleSessionBytes ssb : fetchBytes) {
log.debug("生成向客户端回复的消息 <sessionBytes-SerialNumber {}", ssb.sessionBytes.getSerialNumber());
log.debug("生成向客户端回复的消息 <sessionBytes-SerialNumber {}", ssb.sessionBytes().getSerialNumber());
}
}

sessionBytes = new ArrayList<>(fetchBytes.size());
for (SendAbleSessionBytes ssb : fetchBytes) {
SessionBytes fetchByte = ssb.sessionBytes;
SessionBytes fetchByte = ssb.sessionBytes();
sessionBytes.add(fetchByte);
}
empty = false;
Expand Down Expand Up @@ -167,7 +167,7 @@ public static void replyToClient(CommonConfig config, ServerSessionManager serve

if (null != fetchBytes) {
for (SendAbleSessionBytes fetchByte : fetchBytes) {
sendAbleSessionBytesResultQueue.add(new SendAbleSessionBytesResult(success, fetchByte.callBack));
sendAbleSessionBytesResultQueue.add(new SendAbleSessionBytesResult(success, fetchByte.callBack()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public PortReceiver(ScConfig config, ClientSessionService clientSessionService)
}
log.info("连接建立完成");
Thread.startVirtualThread(() -> {
//休眠一下等待clientSessionService初始化完成,解决native下启动时可能得空指针问题
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//建立连接后,获取时间戳
clientSessionService.sendBytesToServer(GridAesCipherUtil.encrypt("dt".getBytes(StandardCharsets.UTF_8)));
//等待时间戳返回
Expand Down

0 comments on commit 201f478

Please sign in to comment.