Merge pull request #46 from mrbig/master
Remove singleton instances once the client is finished
This commit is contained in:
commit
b5beeca0db
|
@ -139,6 +139,7 @@ public class TCPClient extends StatefulTransportLayerClient {
|
|||
getInStream().close();
|
||||
getOutStream().close();
|
||||
getTcpSocketToServer().close();
|
||||
uniqueTCPClientInstance = null;
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (IOException e) {
|
||||
getLogger().error("Error occurred while trying to close TCP socket to server", e);
|
||||
|
|
|
@ -220,6 +220,7 @@ public class TLSClient extends StatefulTransportLayerClient {
|
|||
getInStream().close();
|
||||
getOutStream().close();
|
||||
getTlsSocketToServer().close();
|
||||
uniqueTLSClientInstance = null;
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (IOException e) {
|
||||
getLogger().error("Error occurred while trying to close TCP socket to server", e);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class UDPClient {
|
|||
* access the instance variable -> thread safe.
|
||||
*/
|
||||
private Logger logger = LogManager.getLogger(this.getClass().getSimpleName());
|
||||
private static final UDPClient uniqueUDPClientInstance = new UDPClient();
|
||||
private static UDPClient uniqueUDPClientInstance = new UDPClient();
|
||||
private int multicastSocketPort;
|
||||
private Inet6Address multicastAddress;
|
||||
private MulticastSocket socketToUDPServer;
|
||||
|
@ -105,7 +105,10 @@ public class UDPClient {
|
|||
}
|
||||
|
||||
|
||||
public static UDPClient getInstance() {
|
||||
public static synchronized UDPClient getInstance() {
|
||||
if (uniqueUDPClientInstance == null) {
|
||||
uniqueUDPClientInstance = new UDPClient();
|
||||
}
|
||||
return uniqueUDPClientInstance;
|
||||
}
|
||||
|
||||
|
@ -144,6 +147,7 @@ public class UDPClient {
|
|||
public void stop() {
|
||||
getSocketToUDPServer().close();
|
||||
getLogger().debug("UDP client stopped");
|
||||
uniqueUDPClientInstance = null;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue