From d0d0f4ec9f19e5879b6922e577d54365f48bb667 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Dec 2013 17:41:17 +1100 Subject: [PATCH] Make getPlayers a little safer. Should probably use a CopyOnWrite collection though. --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 2 +- proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 37a754ee..7761ba2f 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -399,7 +399,7 @@ public class BungeeCord extends ProxyServer connectionLock.readLock().lock(); try { - return (Collection) new HashSet<>( connections.values() ); + return Collections.unmodifiableCollection( new HashSet( connections.values() ) ); } finally { connectionLock.readLock().unlock(); diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java index 48e46ed1..be96fb50 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeServerInfo.java @@ -10,6 +10,7 @@ import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedList; import java.util.Objects; import java.util.Queue; @@ -60,7 +61,7 @@ public class BungeeServerInfo implements ServerInfo @Override public Collection getPlayers() { - return Collections.unmodifiableCollection( players ); + return Collections.unmodifiableCollection( new HashSet( players ) ); } @Override