aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-30 15:10:15 +0700
committerGravatar Alexander Alexeev2016-11-30 15:10:15 +0700
commit1d837a835c04078ec66325e9fb9de21ac401874e (patch)
tree428217d2c617b9caf2eb6d42a7716789881d0937 /juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
parentb45c000ed478f2407288aab1532425288f998689 (diff)
prevent string concatenation for disabled loggers
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/XMPPConnection.java')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index b75ca998..f535d123 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -68,7 +68,8 @@ public class XMPPConnection implements AutoCloseable {
Message msg = e.getMessage();
com.juick.Message jmsg = msg.getExtension(com.juick.Message.class);
if (jmsg != null) {
- logger.info("got msg: " + ms.writeValueAsString(jmsg));
+ if (logger.isInfoEnabled()) // prevent writeValueAsString execution if log is disabled
+ logger.info("got msg: {}", ms.writeValueAsString(jmsg));
if (jmsg.getMid() == 0) {
int uid_to = NumberUtils.toInt(msg.getTo().getLocal(), 0);
if (uid_to > 0) {
@@ -106,7 +107,7 @@ public class XMPPConnection implements AutoCloseable {
synchronized (wsHandler.getClients()) {
wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUid() == uid_to).forEach(c -> {
try {
- logger.info("sending pm to " + c.visitor.getUid());
+ logger.info("sending pm to {}", c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -125,7 +126,7 @@ public class XMPPConnection implements AutoCloseable {
|| (!c.legacy && uids.contains(c.visitor.getUid()))) // subscriptions
.forEach(c -> {
try {
- logger.info("sending message to " + c.visitor.getUid());
+ logger.info("sending message to {}", c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -135,7 +136,7 @@ public class XMPPConnection implements AutoCloseable {
c.legacy && c.allMessages) // legacy all posts
.forEach(c -> {
try {
- logger.info("sending message to legacy client " + c.visitor.getUid());
+ logger.info("sending message to legacy client {}", c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -155,7 +156,7 @@ public class XMPPConnection implements AutoCloseable {
|| (!c.legacy && threadUsers.contains(c.visitor.getUid()))) // subscriptions
.forEach(c -> {
try {
- logger.info("sending reply to " + c.visitor.getUid());
+ logger.info("sending reply to {}", c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);
@@ -165,7 +166,7 @@ public class XMPPConnection implements AutoCloseable {
(c.legacy && c.allReplies) || (c.legacy && c.MID == jmsg.getMid())) // legacy replies
.forEach(c -> {
try {
- logger.info("sending reply to legacy client " + c.visitor.getUid());
+ logger.info("sending reply to legacy client {}", c.visitor.getUid());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
logger.warn("ws error", e);