From 7525386ed63173f4e598d7c830f659ddff564014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Wo=CC=81jcik?= Date: Tue, 5 Jul 2016 15:13:05 +0200 Subject: [PATCH] Issue #4317 - fix for NPE in Socks5ConnectionManager --- .../Socks5ConnectionManager.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/jaxmpp-j2se/src/main/java/tigase/jaxmpp/j2se/connection/socks5bytestream/Socks5ConnectionManager.java b/jaxmpp-j2se/src/main/java/tigase/jaxmpp/j2se/connection/socks5bytestream/Socks5ConnectionManager.java index 156d2f7c..6b34d53e 100644 --- a/jaxmpp-j2se/src/main/java/tigase/jaxmpp/j2se/connection/socks5bytestream/Socks5ConnectionManager.java +++ b/jaxmpp-j2se/src/main/java/tigase/jaxmpp/j2se/connection/socks5bytestream/Socks5ConnectionManager.java @@ -17,21 +17,6 @@ */ package tigase.jaxmpp.j2se.connection.socks5bytestream; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.nio.ByteBuffer; -import java.nio.channels.ClosedChannelException; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Level; -import java.util.logging.Logger; - import tigase.jaxmpp.core.client.*; import tigase.jaxmpp.core.client.XMPPException.ErrorCondition; import tigase.jaxmpp.core.client.exceptions.JaxmppException; @@ -49,6 +34,21 @@ import tigase.jaxmpp.j2se.filetransfer.FileTransfer; import tigase.jaxmpp.j2se.filetransfer.FileTransferManager; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.nio.charset.Charset; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * * @author andrzej @@ -334,7 +334,9 @@ protected static void unregisterSession(ConnectionSession session) { sessions.remove(hash); if (sessions.isEmpty()) { - server.shutdown(); + if (server != null) { + server.shutdown(); + } } } }