Madan Jampani

Fix potential deadlock in CopycatTransport

Change-Id: Ic8ac913c25dcc68b66ec96767a60d44340c89568
...@@ -92,9 +92,7 @@ public class CopycatTransport implements Transport { ...@@ -92,9 +92,7 @@ public class CopycatTransport implements Transport {
92 public static Endpoint toEndpoint(Address address) { 92 public static Endpoint toEndpoint(Address address) {
93 return EP_LOOKUP_CACHE.computeIfAbsent(address, a -> { 93 return EP_LOOKUP_CACHE.computeIfAbsent(address, a -> {
94 try { 94 try {
95 - Endpoint endpoint = new Endpoint(IpAddress.valueOf(InetAddress.getByName(a.host())), a.port()); 95 + return new Endpoint(IpAddress.valueOf(InetAddress.getByName(a.host())), a.port());
96 - ADDRESS_LOOKUP_CACHE.putIfAbsent(endpoint, address);
97 - return endpoint;
98 } catch (UnknownHostException e) { 96 } catch (UnknownHostException e) {
99 Throwables.propagate(e); 97 Throwables.propagate(e);
100 return null; 98 return null;
...@@ -112,9 +110,7 @@ public class CopycatTransport implements Transport { ...@@ -112,9 +110,7 @@ public class CopycatTransport implements Transport {
112 try { 110 try {
113 InetAddress host = InetAddress.getByAddress(endpoint.host().toOctets()); 111 InetAddress host = InetAddress.getByAddress(endpoint.host().toOctets());
114 int port = endpoint.port(); 112 int port = endpoint.port();
115 - Address address = new Address(new InetSocketAddress(host, port)); 113 + return new Address(new InetSocketAddress(host, port));
116 - EP_LOOKUP_CACHE.putIfAbsent(address, endpoint);
117 - return address;
118 } catch (UnknownHostException e) { 114 } catch (UnknownHostException e) {
119 Throwables.propagate(e); 115 Throwables.propagate(e);
120 return null; 116 return null;
......