Removed redundant toString call
This commit is contained in:
parent
6be61ed821
commit
b58a4b3b06
@ -166,7 +166,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("{} Failed to decode subscription cmd: {}", sessionRef.toString(), e.getMessage(), e);
|
log.debug("{} Failed to decode subscription cmd: {}", sessionRef, e.getMessage(), e);
|
||||||
if (sessionRef.getSecurityCtx() != null) {
|
if (sessionRef.getSecurityCtx() != null) {
|
||||||
webSocketService.sendError(sessionRef, 1, SubscriptionErrorCode.BAD_REQUEST, "Failed to parse the payload");
|
webSocketService.sendError(sessionRef, 1, SubscriptionErrorCode.BAD_REQUEST, "Failed to parse the payload");
|
||||||
} else {
|
} else {
|
||||||
@ -176,7 +176,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sessionRef.getSecurityCtx() != null) {
|
if (sessionRef.getSecurityCtx() != null) {
|
||||||
log.trace("{} Processing {}", sessionRef.toString(), msg);
|
log.trace("{} Processing {}", sessionRef, msg);
|
||||||
webSocketService.handleCommands(sessionRef, cmdsWrapper);
|
webSocketService.handleCommands(sessionRef, cmdsWrapper);
|
||||||
} else {
|
} else {
|
||||||
AuthCmd authCmd = cmdsWrapper.getAuthCmd();
|
AuthCmd authCmd = cmdsWrapper.getAuthCmd();
|
||||||
@ -184,7 +184,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Auth cmd is missing"));
|
close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Auth cmd is missing"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.trace("{} Authenticating session", sessionRef.toString());
|
log.trace("{} Authenticating session", sessionRef);
|
||||||
SecurityUser securityCtx;
|
SecurityUser securityCtx;
|
||||||
try {
|
try {
|
||||||
securityCtx = authenticationProvider.authenticate(authCmd.getToken());
|
securityCtx = authenticationProvider.authenticate(authCmd.getToken());
|
||||||
@ -205,7 +205,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
try {
|
try {
|
||||||
SessionMetaData sessionMd = getSessionMd(session.getId());
|
SessionMetaData sessionMd = getSessionMd(session.getId());
|
||||||
if (sessionMd != null) {
|
if (sessionMd != null) {
|
||||||
log.trace("{} Processing pong response {}", sessionMd.sessionRef.toString(), message.getPayload());
|
log.trace("{} Processing pong response {}", sessionMd.sessionRef, message.getPayload());
|
||||||
sessionMd.processPongMessage(System.currentTimeMillis());
|
sessionMd.processPongMessage(System.currentTimeMillis());
|
||||||
} else {
|
} else {
|
||||||
log.trace("[{}] Failed to find session", session.getId());
|
log.trace("[{}] Failed to find session", session.getId());
|
||||||
@ -289,7 +289,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
cleanupLimits(session, sessionMd.sessionRef);
|
cleanupLimits(session, sessionMd.sessionRef);
|
||||||
processInWebSocketService(sessionMd.sessionRef, SessionEvent.onClosed());
|
processInWebSocketService(sessionMd.sessionRef, SessionEvent.onClosed());
|
||||||
}
|
}
|
||||||
log.info("{} Session is closed", sessionMd.sessionRef.toString());
|
log.info("{} Session is closed", sessionMd.sessionRef);
|
||||||
} else {
|
} else {
|
||||||
log.info("[{}] Session is closed", session.getId());
|
log.info("[{}] Session is closed", session.getId());
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
try {
|
try {
|
||||||
webSocketService.handleSessionEvent(sessionRef, event);
|
webSocketService.handleSessionEvent(sessionRef, event);
|
||||||
} catch (BeanCreationNotAllowedException e) {
|
} catch (BeanCreationNotAllowedException e) {
|
||||||
log.warn("{} Failed to close session due to possible shutdown state", sessionRef.toString());
|
log.warn("{} Failed to close session due to possible shutdown state", sessionRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,13 +368,13 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
try {
|
try {
|
||||||
long timeSinceLastActivity = currentTime - lastActivityTime;
|
long timeSinceLastActivity = currentTime - lastActivityTime;
|
||||||
if (timeSinceLastActivity >= pingTimeout) {
|
if (timeSinceLastActivity >= pingTimeout) {
|
||||||
log.warn("{} Closing session due to ping timeout", sessionRef.toString());
|
log.warn("{} Closing session due to ping timeout", sessionRef);
|
||||||
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
||||||
} else if (timeSinceLastActivity >= pingTimeout / NUMBER_OF_PING_ATTEMPTS) {
|
} else if (timeSinceLastActivity >= pingTimeout / NUMBER_OF_PING_ATTEMPTS) {
|
||||||
sendMsg(TbWebSocketPingMsg.INSTANCE);
|
sendMsg(TbWebSocketPingMsg.INSTANCE);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.trace("{} Failed to send ping msg", sessionRef.toString(), e);
|
log.trace("{} Failed to send ping msg", sessionRef, e);
|
||||||
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
try {
|
try {
|
||||||
close(this.sessionRef, reason);
|
close(this.sessionRef, reason);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
log.trace("{} Session transport error", sessionRef.toString(), ioe);
|
log.trace("{} Session transport error", sessionRef, ioe);
|
||||||
} finally {
|
} finally {
|
||||||
outboundMsgQueue.clear();
|
outboundMsgQueue.clear();
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
outboundMsgQueueSize.incrementAndGet();
|
outboundMsgQueueSize.incrementAndGet();
|
||||||
processNextMsg();
|
processNextMsg();
|
||||||
} else {
|
} else {
|
||||||
log.info("{} Session closed due to updates queue size exceeded", sessionRef.toString());
|
log.info("{} Session closed due to updates queue size exceeded", sessionRef);
|
||||||
closeSession(CloseStatus.POLICY_VIOLATION.withReason("Max pending updates limit reached!"));
|
closeSession(CloseStatus.POLICY_VIOLATION.withReason("Max pending updates limit reached!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
processNextMsg();
|
processNextMsg();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.trace("{} Failed to send msg", sessionRef.toString(), e);
|
log.trace("{} Failed to send msg", sessionRef, e);
|
||||||
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,7 +429,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
@Override
|
@Override
|
||||||
public void onResult(SendResult result) {
|
public void onResult(SendResult result) {
|
||||||
if (!result.isOK()) {
|
if (!result.isOK()) {
|
||||||
log.trace("{} Failed to send msg", sessionRef.toString(), result.getException());
|
log.trace("{} Failed to send msg", sessionRef, result.getException());
|
||||||
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
closeSession(CloseStatus.SESSION_NOT_RELIABLE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(WebSocketSessionRef sessionRef, int subscriptionId, String msg) throws IOException {
|
public void send(WebSocketSessionRef sessionRef, int subscriptionId, String msg) throws IOException {
|
||||||
log.debug("{} Sending {}", sessionRef.toString(), msg);
|
log.debug("{} Sending {}", sessionRef, msg);
|
||||||
String externalId = sessionRef.getSessionId();
|
String externalId = sessionRef.getSessionId();
|
||||||
String internalId = externalSessionMap.get(externalId);
|
String internalId = externalSessionMap.get(externalId);
|
||||||
if (internalId != null) {
|
if (internalId != null) {
|
||||||
@ -485,12 +485,12 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
|
|||||||
TenantId tenantId = sessionRef.getSecurityCtx().getTenantId();
|
TenantId tenantId = sessionRef.getSecurityCtx().getTenantId();
|
||||||
if (!rateLimitService.checkRateLimit(LimitedApi.WS_UPDATES_PER_SESSION, tenantId, (Object) sessionRef.getSessionId())) {
|
if (!rateLimitService.checkRateLimit(LimitedApi.WS_UPDATES_PER_SESSION, tenantId, (Object) sessionRef.getSessionId())) {
|
||||||
if (blacklistedSessions.putIfAbsent(externalId, sessionRef) == null) {
|
if (blacklistedSessions.putIfAbsent(externalId, sessionRef) == null) {
|
||||||
log.info("{} Failed to process session update. Max session updates limit reached", sessionRef.toString());
|
log.info("{} Failed to process session update. Max session updates limit reached", sessionRef);
|
||||||
sessionMd.sendMsg("{\"subscriptionId\":" + subscriptionId + ", \"errorCode\":" + ThingsboardErrorCode.TOO_MANY_UPDATES.getErrorCode() + ", \"errorMsg\":\"Too many updates!\"}");
|
sessionMd.sendMsg("{\"subscriptionId\":" + subscriptionId + ", \"errorCode\":" + ThingsboardErrorCode.TOO_MANY_UPDATES.getErrorCode() + ", \"errorMsg\":\"Too many updates!\"}");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
log.debug("{} Session is no longer blacklisted.", sessionRef.toString());
|
log.debug("{} Session is no longer blacklisted.", sessionRef);
|
||||||
blacklistedSessions.remove(externalId);
|
blacklistedSessions.remove(externalId);
|
||||||
}
|
}
|
||||||
sessionMd.sendMsg(msg);
|
sessionMd.sendMsg(msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user