Skip to content

Commit fe9bf0d

Browse files
committed
fix(sdk-java): 响应路由回归——pending reqId 优先匹配,请求帧才走 inbound
上提交把路由改成先判 isResponse 再查 pending,破坏了既有语义: mock/旧对端可能用非标准响应 msgId(如 0x030106)回帧——先判类型 导致这类帧既不 signal pending 也不 dispatch,请求挂起超时 (TCPTransportEdgeTest 两例失败:idle read / malformed skip)。 恢复原顺序:按 pending reqId 匹配优先(不看 msgId 类型),未命中 且 isRequest 才 inbound 分发。全量 gradle test 通过。
1 parent b9397da commit fe9bf0d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

sdks/java/src/main/java/io/github/cuihairu/croupier/sdk/transport/TCPTransport.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,16 @@ private void readLoop() {
272272
byte[] body = new byte[payload.length - PROTOCOL_HEADER_SIZE];
273273
System.arraycopy(payload, PROTOCOL_HEADER_SIZE, body, 0, body.length);
274274

275-
if (Protocol.isResponse(msgId)) {
276-
// Route to pending request
277-
ResponseLatch latch = pendingResponses.get(reqId);
278-
if (latch != null) {
279-
latch.signal(body, msgId);
280-
} else {
281-
LOG.debug("No pending request for reqId: {}", reqId);
282-
}
275+
// 响应优先按 pending reqId 匹配(保持既有语义:mock/旧对端
276+
// 可能用非标准响应 msgId 回帧);未命中 pending 且是请求帧
277+
// 才走 inbound 分发(Agent -> Provider 调用)。
278+
ResponseLatch latch = pendingResponses.get(reqId);
279+
if (latch != null) {
280+
latch.signal(body, msgId);
283281
} else if (Protocol.isRequest(msgId)) {
284282
dispatchInbound(msgId, reqId, body);
283+
} else {
284+
LOG.debug("No pending request for reqId: {}", reqId);
285285
}
286286
}
287287
} catch (IOException e) {

0 commit comments

Comments
 (0)