Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor, replace some deprecated methods related with jedis and UT #1040

Merged
merged 8 commits into from
Feb 24, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void deferExpired() {
break;//  If the server side has synchronized data, just write a single machine
}
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) {
logger.warn("Failed to write provider heartbeat to redis registry. registry: " + entry.getKey() + ", cause: " + t.getMessage(), t);
Expand Down Expand Up @@ -230,7 +230,7 @@ public boolean isAvailable() {
return true; // At least one single machine is available.
}
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) {
}
Expand Down Expand Up @@ -282,7 +282,7 @@ public void doRegister(URL url) {
break; //  If the server side has synchronized data, just write a single machine
}
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) {
exception = new RpcException("Failed to register service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
Expand Down Expand Up @@ -315,7 +315,7 @@ public void doUnregister(URL url) {
break; //  If the server side has synchronized data, just write a single machine
}
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) {
exception = new RpcException("Failed to unregister service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
Expand Down Expand Up @@ -373,7 +373,7 @@ public void doSubscribe(final URL url, final NotifyListener listener) {
success = true;
break; // Just read one server's data
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) { // Try the next server
exception = new RpcException("Failed to subscribe service from redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
Expand Down Expand Up @@ -498,7 +498,7 @@ public void onMessage(String key, String msg) {
try {
doNotify(jedis, key);
} finally {
jedisPool.returnResource(jedis);
jedis.close();
}
} catch (Throwable t) { // TODO Notification failure does not restore mechanism guarantee
logger.error(t.getMessage(), t);
Expand Down Expand Up @@ -602,7 +602,7 @@ public void run() {
}
break;
} finally {
jedisPool.returnBrokenResource(jedis);
jedis.close();
}
} catch (Throwable t) { // Retry another server
logger.warn("Failed to subscribe service from redis registry. registry: " + entry.getKey() + ", cause: " + t.getMessage(), t);
Expand Down