13
0

Fix synchronisation issues

Dieser Commit ist enthalten in:
Lixfel 2021-09-11 17:12:41 +02:00
Ursprung ad94e77042
Commit 8acdd3cb7f

Datei anzeigen

@ -46,16 +46,20 @@ public class Subserver implements Runnable {
private static final Logger logger = ProxyServer.getInstance().getLogger(); private static final Logger logger = ProxyServer.getInstance().getLogger();
public static Subserver getSubserver(ProxiedPlayer p){ public static Subserver getSubserver(ProxiedPlayer p){
for(int i = serverList.size()-1; i >= 0; i--){ synchronized (serverList) {
if(serverList.get(i).onServer(p)) for(int i = serverList.size()-1; i >= 0; i--){
return serverList.get(i); if(serverList.get(i).onServer(p))
return serverList.get(i);
}
} }
return null; return null;
} }
public static Subserver getSubserver(ServerInfo server){ public static Subserver getSubserver(ServerInfo server){
for(Subserver s : serverList) synchronized (serverList) {
if(s.server == server) for(Subserver s : serverList)
return s; if(s.server == server)
return s;
}
return null; return null;
} }
public static List<Subserver> getServerList(){ public static List<Subserver> getServerList(){
@ -179,7 +183,9 @@ public class Subserver implements Runnable {
public void run(){ public void run(){
ProxyServer.getInstance().getServers().put(serverName, server); ProxyServer.getInstance().getServers().put(serverName, server);
serverList.add(this); synchronized (serverList) {
serverList.add(this);
}
try(BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))){ try(BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))){
String line = ""; String line = "";