Skip to content

Commit a21ff1f

Browse files
rajaprabhuXinzhi Zou
authored and
Xinzhi Zou
committed
Fix to fall back to key based config in binary mode for 1.4.5 engine
1 parent 69cf4d5 commit a21ff1f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main/java/net/spy/memcached/ConfigurationPoller.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ public void run(){
115115
newConfigResponse = (String)client.getConfig(socketAddressToGetConfig,
116116
ConfigurationType.CLUSTER,
117117
configTranscoder);
118+
if(newConfigResponse == null || newConfigResponse.trim().isEmpty()){
119+
newConfigResponse = (String)client.get(socketAddressToGetConfig, ConfigurationType.CLUSTER.getValueWithNameSpace(), configTranscoder);
120+
if(newConfigResponse != null && ! newConfigResponse.trim().isEmpty()){
121+
client.setIsConfigurationProtocolSupported(false);
122+
}
123+
}
124+
118125
}catch(OperationNotSupportedException e){
119126
//Fallback to key based config access.
120127
client.setIsConfigurationProtocolSupported(false);

src/main/java/net/spy/memcached/MemcachedClient.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,21 @@ private void initializeClientUsingConfigEndPoint(ConnectionFactory cf, InetSocke
316316
throws IOException{
317317
configurationNode = new NodeEndPoint(configurationEndPoint.getHostName(), configurationEndPoint.getPort());
318318
setupConnection(cf, Collections.singletonList(configurationEndPoint));
319-
320-
String configResult;
319+
boolean checkKey = false;
320+
String configResult = null;
321321
try{
322322
try{
323323
//GetConfig
324324
configResult = (String)this.getConfig(configurationEndPoint, ConfigurationType.CLUSTER, configTranscoder);
325325
}catch(OperationNotSupportedException e){
326-
326+
checkKey = true;
327+
}
328+
329+
if(checkKey || configResult == null || configResult.trim().isEmpty()){
327330
configResult = (String)this.get(configurationEndPoint, ConfigurationType.CLUSTER.getValueWithNameSpace(), configTranscoder);
328-
isConfigurationProtocolSupported = false;
331+
if(configResult != null && ! configResult.trim().isEmpty()){
332+
isConfigurationProtocolSupported = false;
333+
}
329334
}
330335

331336
if(configResult != null && ! configResult.trim().isEmpty()){

0 commit comments

Comments
 (0)