[FIX][EXPERIMENTAL] Фикс возможных проблем с requestUUID

This commit is contained in:
Gravit 2019-05-03 23:38:20 +07:00
parent fcacd4fe12
commit 6a70a23556
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -40,6 +40,7 @@
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
import java.util.UUID;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class WebSocketService { public class WebSocketService {
@ -67,16 +68,23 @@ void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client)
{ {
if(server.config.netty.proxy.requests.contains(response.getType())) if(server.config.netty.proxy.requests.contains(response.getType()))
{ {
UUID origRequestUUID = null;
if(response instanceof SimpleResponse) if(response instanceof SimpleResponse)
{ {
SimpleResponse simpleResponse = (SimpleResponse) response; SimpleResponse simpleResponse = (SimpleResponse) response;
simpleResponse.server = server; simpleResponse.server = server;
simpleResponse.service = this; simpleResponse.service = this;
simpleResponse.ctx = ctx; simpleResponse.ctx = ctx;
origRequestUUID = simpleResponse.requestUUID;
} }
LogHelper.debug("Proxy %s request", response.getType()); LogHelper.debug("Proxy %s request", response.getType());
if(client.session == 0) client.session = new Random().nextLong(); if(client.session == 0) client.session = new Random().nextLong();
ProxyRequest proxyRequest = new ProxyRequest(response, client.session); ProxyRequest proxyRequest = new ProxyRequest(response, client.session);
if(response instanceof SimpleResponse)
{
((SimpleResponse) response).requestUUID = proxyRequest.requestUUID;
}
proxyRequest.isCheckSign = client.checkSign; proxyRequest.isCheckSign = client.checkSign;
try { try {
ResultInterface result = proxyRequest.request(); ResultInterface result = proxyRequest.request();
@ -90,7 +98,7 @@ void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client)
} }
if(result instanceof Request && response instanceof SimpleResponse) if(result instanceof Request && response instanceof SimpleResponse)
{ {
((Request) result).requestUUID = ((SimpleResponse) response).requestUUID; ((Request) result).requestUUID = origRequestUUID;
} }
sendObject(ctx, result); sendObject(ctx, result);
} catch (RequestException e) } catch (RequestException e)