2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

Use Google Guava InetAddresses.forString() method to make sure we don't hit network.

This commit is contained in:
Marquee 2015-02-05 22:11:22 -05:00
parent 144fe4d2fb
commit d1bdfc9e2e

View File

@ -6,6 +6,7 @@
*/ */
package com.imaginarycode.minecraft.redisbungee; package com.imaginarycode.minecraft.redisbungee;
import com.google.common.net.InetAddresses;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -24,7 +25,6 @@ import redis.clients.jedis.Jedis;
import redis.clients.jedis.exceptions.JedisConnectionException; import redis.clients.jedis.exceptions.JedisConnectionException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
@ -122,11 +122,7 @@ public class DataManager implements Listener {
try { try {
String result = tmpRsc.hget("player:" + uuid, "ip"); String result = tmpRsc.hget("player:" + uuid, "ip");
if (result != null) { if (result != null) {
address = InetAddress.getByName(result); address = InetAddresses.forString(result);
if (address == null)
return null;
ipCache.put(uuid, address); ipCache.put(uuid, address);
return address; return address;
} }
@ -137,8 +133,6 @@ public class DataManager implements Listener {
if (tmpRsc != null) if (tmpRsc != null)
plugin.getPool().returnBrokenResource(tmpRsc); plugin.getPool().returnBrokenResource(tmpRsc);
throw new RuntimeException("Unable to get server for " + uuid, e); throw new RuntimeException("Unable to get server for " + uuid, e);
} catch (UnknownHostException e) {
return null;
} finally { } finally {
plugin.getPool().returnResource(tmpRsc); plugin.getPool().returnResource(tmpRsc);
} }