From b2a65a6b63e8691b0101f4652705fab79dc26d99 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 7 Dec 2016 12:37:43 +0300 Subject: juick-xmpp: refactoring --- .../com/juick/components/s2s/ConnectionOut.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java') diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java index 7a6ae122..0111601e 100644 --- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java +++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java @@ -61,7 +61,7 @@ public class ConnectionOut extends Connection implements Runnable { @Override public void run() { - logger.info("STREAM TO {} START", to); + logger.info("stream to {} start", to); try { socket = new Socket(); socket.connect(DNSQueries.getServerAddress(to)); @@ -72,10 +72,10 @@ public class ConnectionOut extends Connection implements Runnable { parser.next(); // stream:stream streamID = parser.getAttributeValue(null, "id"); if (streamID == null || streamID.isEmpty()) { - throw new Exception("STREAM TO " + to + " INVALID FIRST PACKET"); + throw new Exception("stream to " + to + " invalid first packet"); } - logger.info("STREAM TO {} {} OPEN", to, streamID); + logger.info("stream to {} {} open", to, streamID); xmpp.addConnectionOut(ConnectionOut.this); boolean xmppversionnew = parser.getAttributeValue(null, "version") != null; if (!xmppversionnew) { @@ -93,16 +93,16 @@ public class ConnectionOut extends Connection implements Runnable { String type = parser.getAttributeValue(null, "type"); if (type != null && type.equals("valid")) { streamReady = true; - logger.info("STREAM TO {} {} READY", to, streamID); + logger.info("stream to {} {} ready", to, streamID); String cache = xmpp.getFromCache(to); if (cache != null) { - logger.info("STREAM TO {} {} SENDING CACHE", to, streamID); + logger.info("stream to {} {} sending cache", to, streamID); sendStanza(cache); } } else { - logger.info("STREAM TO {} {} DIALBACK FAIL", to, streamID); + logger.info("stream to {} {} dialback fail", to, streamID); } XmlUtils.skip(parser); } else if (tag.equals("verify") && parser.getNamespace().equals(NS_DB)) { @@ -119,7 +119,7 @@ public class ConnectionOut extends Connection implements Runnable { } else if (tag.equals("features") && parser.getNamespace().equals(NS_STREAM)) { StreamFeatures features = StreamFeatures.parse(parser); if (sc != null && !isSecured() && features.STARTTLS >= 0 && !xmpp.brokenSSLhosts.contains(to)) { - logger.info("STREAM TO {} {} SECURING", to, streamID); + logger.info("stream to {} {} securing", to, streamID); sendStanza(""); } else { processDialback(); @@ -130,7 +130,7 @@ public class ConnectionOut extends Connection implements Runnable { socket.getPort(), true); ((SSLSocket) socket).startHandshake(); setSecured(true); - logger.info("STREAM {} SECURED", streamID); + logger.info("stream {} secured", streamID); restartParser(); sendOpenStream(); } catch (SSLException sex) { @@ -142,16 +142,16 @@ public class ConnectionOut extends Connection implements Runnable { } else if (isSecured() && tag.equals("stream") && parser.getNamespace().equals(NS_STREAM)) { streamID = parser.getAttributeValue(null, "id"); } else { - if (logger.isInfoEnabled()) // prevent parseToString call if logger disabled - logger.info("STREAM TO {} {} : {}", to, streamID, XmlUtils.parseToString(parser, true)); + String unhandledStanza = XmlUtils.parseToString(parser, true); + logger.warn("Unhandled stanza from {} {} : {}", to, streamID, unhandledStanza); } } - logger.warn("STREAM TO {} {} FINISHED", to, streamID); + logger.warn("stream to {} {} finished", to, streamID); xmpp.removeConnectionOut(ConnectionOut.this); closeConnection(); } catch (EOFException | SocketException eofex) { - logger.info("STREAM {} {} CLOSED (dirty)", to, streamID); + logger.info("stream {} {} closed (dirty)", to, streamID); xmpp.removeConnectionOut(ConnectionOut.this); closeConnection(); } catch (Exception e) { @@ -165,7 +165,7 @@ public class ConnectionOut extends Connection implements Runnable { try { sendStanza("" + key + ""); } catch (IOException e) { - logger.warn("STREAM TO {} {} ERROR {}", to, streamID, e); + logger.warn("stream to {} {} error {}", to, streamID, e); } } } -- cgit v1.2.3