From 914fee9ae45c956a895555a48d47af434af444aa Mon Sep 17 00:00:00 2001 From: alexVengrovsk Date: Mon, 12 Oct 2015 13:53:55 +0300 Subject: [PATCH] Add isDebugEnabled() check It is good thing to make this checks because of expensive concatenation of String objects (debug messages). --- .../event/LeaseManagerMessageBroker.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/LeaseManagerMessageBroker.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/LeaseManagerMessageBroker.java index 5d802b07..d71071e4 100644 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/LeaseManagerMessageBroker.java +++ b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/LeaseManagerMessageBroker.java @@ -45,8 +45,10 @@ public class LeaseManagerMessageBroker implements LeaseManagerLite @Override public void register(InstanceInfo info, int leaseDuration, boolean isReplication) { - log.debug("register " + info.getAppName() + ", vip " + info.getVIPAddress() - + ", leaseDuration " + leaseDuration + ", isReplication " + isReplication); + if (log.isDebugEnabled()) { + log.debug("register " + info.getAppName() + ", vip " + info.getVIPAddress() + + ", leaseDuration " + leaseDuration + ", isReplication " + isReplication); + } // TODO: what to publish from info (whole object?) this.ctxt.publishEvent(new EurekaInstanceRegisteredEvent(this, info, leaseDuration, isReplication)); @@ -54,8 +56,10 @@ public class LeaseManagerMessageBroker implements LeaseManagerLite @Override public boolean cancel(String appName, String serverId, boolean isReplication) { - log.debug("cancel " + appName + " serverId " + serverId + ", isReplication {}" - + isReplication); + if (log.isDebugEnabled()) { + log.debug("cancel " + appName + " serverId " + serverId + ", isReplication {}" + + isReplication); + } this.ctxt.publishEvent(new EurekaInstanceCanceledEvent(this, appName, serverId, isReplication)); return false; @@ -64,8 +68,10 @@ public class LeaseManagerMessageBroker implements LeaseManagerLite @Override public boolean renew(final String appName, final String serverId, boolean isReplication) { - log.debug("renew " + appName + " serverId " + serverId + ", isReplication {}" - + isReplication); + if (log.isDebugEnabled()) { + log.debug("renew " + appName + " serverId " + serverId + ", isReplication {}" + + isReplication); + } List applications = PeerAwareInstanceRegistryImpl.getInstance() .getSortedApplications(); for (Application input : applications) {