Skip to content

Commit

Permalink
Fix performance issues caused by debuglog (#1332)
Browse files Browse the repository at this point in the history
Signed-off-by: JermaineHua <[email protected]>
  • Loading branch information
CrazyHZM authored Aug 2, 2024
1 parent 62005e2 commit f180dab
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ public Object doInvoke(MethodInvocation invocation) throws Throwable {
+ "] has already been destroyed.");
}

SofaLogger.debug(">> Start in JVM service invoke, the service interface is - {}",
getInterfaceName());
if (SofaLogger.isDebugEnabled()) {
SofaLogger.debug(">> Start in JVM service invoke, the service interface is - {}",
getInterfaceName());
}

Object retVal;
Object targetObj = this.getTarget();
Expand All @@ -225,17 +227,21 @@ public Object doInvoke(MethodInvocation invocation) throws Throwable {
try {
return serviceProxy.invoke(invocation);
} finally {
SofaLogger.debug(
"<< Finish Cross App JVM service invoke, the service is - {}]",
(getInterfaceName() + "#" + getUniqueId()));
if (SofaLogger.isDebugEnabled()) {
SofaLogger.debug(
"<< Finish Cross App JVM service invoke, the service is - {}]",
(getInterfaceName() + "#" + getUniqueId()));
}
}
}
}

if (targetObj == null || ((targetObj instanceof Proxy) && binding.hasBackupProxy())) {
targetObj = binding.getBackupProxy();
SofaLogger.debug("<<{}.{} backup proxy invoke.", getInterfaceName().getName(),
invocation.getMethod().getName());
if (SofaLogger.isDebugEnabled()) {
SofaLogger.debug("<<{}.{} backup proxy invoke.", getInterfaceName().getName(),
invocation.getMethod().getName());
}
}

if (targetObj == null) {
Expand All @@ -250,9 +256,11 @@ public Object doInvoke(MethodInvocation invocation) throws Throwable {
} catch (InvocationTargetException ex) {
throw ex.getTargetException();
} finally {
SofaLogger.debug(
"<< Finish JVM service invoke, the service implementation is - {}]",
(this.target == null ? "null" : this.target.getClass().getName()));
if (SofaLogger.isDebugEnabled()) {
SofaLogger.debug(
"<< Finish JVM service invoke, the service implementation is - {}]",
(this.target == null ? "null" : this.target.getClass().getName()));
}

popThreadContextClassLoader(tcl);
}
Expand Down

0 comments on commit f180dab

Please sign in to comment.