From 9d4c98c466dfd870832da6b66a5e2d0e50f3a05d Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Thu, 2 Apr 2020 02:29:17 +0200 Subject: [PATCH] Fix crash when no server connected to tracker yet --- src/clientP2P/ClientManagement.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/clientP2P/ClientManagement.java b/src/clientP2P/ClientManagement.java index 637ff44..f10d51d 100644 --- a/src/clientP2P/ClientManagement.java +++ b/src/clientP2P/ClientManagement.java @@ -182,6 +182,9 @@ public abstract class ClientManagement extends ServeErrors implements Runnable { * @throws VersionRemoteError */ protected String[] listDirectory() throws EmptyDirectory, InternalError, UnknownHostException, IOException, TransmissionError, ProtocolError, VersionError, SizeError, InternalRemoteError, ProtocolRemoteError, VersionRemoteError { + if (hostList.size() == 0) { + return new String[0]; + } ProtocolP2PPacket d = createProtocolP2PPacket(new Payload(RequestResponseCode.LIST_REQUEST)); try { d.sendRequest(getHostItemSocket(hostList.get(0))); -- 2.30.2