Skip to content

Commit

Permalink
Added a null check for connection provider
Browse files Browse the repository at this point in the history
  • Loading branch information
smadappa committed Jun 15, 2017
1 parent b48e2a6 commit 248c6db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ public DIConnectionModule() {
@Override
// Make sure this is done
protected void configure() {
// if(getProvider(IConnectionBuilder.class) == null && getProvider(IConnectionBuilder.class) instanceof DIConnectionFactoryBuilderProvider) {
if(getProvider(IConnectionBuilder.class) == null ) {
bind(IConnectionBuilder.class).toProvider(DIConnectionFactoryBuilderProvider.class);
// } else {
// Provider<IConnectionBuilder> provider = getProvider(IConnectionBuilder.class);
// System.out.println("provider = " + provider);
// System.out.println("provider.get = " + provider.getClass());
// }
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ public String getKeyForNode(MemcachedNode node, int repetition) {
if(discoveryClient != null ) {
final Application app = discoveryClient.getApplication(client.getAppName());
if(app != null) {
final List<InstanceInfo> instances = app.getInstances();
for(InstanceInfo info : instances) {
final String hostName = info.getHostName();
if(hostName.equalsIgnoreCase(isa.getHostName())) {
final String ip = info.getIPAddr();
final String port = info.getMetadata().get("evcache.port");
result = hostName + '/' + ip + ':' + ((port != null) ? port : "11211");
break;
}
}
final List<InstanceInfo> instances = app.getInstances();
for(InstanceInfo info : instances) {
final String hostName = info.getHostName();
if(hostName.equalsIgnoreCase(isa.getHostName())) {
final String ip = info.getIPAddr();
result = hostName + '/' + ip + ":11211";
break;
}
}
} else {
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
result = ((InetSocketAddress)socketAddress).getHostName() + '/' + ((InetSocketAddress)socketAddress).getAddress().getHostAddress() + ":11211";
}
} else {
result = isa.getHostName() + '/' + isa.getAddress().getHostAddress() + ":11211";
Expand Down

0 comments on commit 248c6db

Please sign in to comment.