You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/08/06 06:13:41 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2314]fix
problem when calling RPC code fail in vert.x worker pool (#2495)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 615a8ca [SCB-2314]fix problem when calling RPC code fail in vert.x worker pool (#2495)
615a8ca is described below
commit 615a8ca8cd7ea6fb85ae19816dfbf3a6b90d7345
Author: liubao68 <bi...@qq.com>
AuthorDate: Fri Aug 6 14:13:36 2021 +0800
[SCB-2314]fix problem when calling RPC code fail in vert.x worker pool (#2495)
---
.../servicecomb/core/provider/consumer/InvokerUtils.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
index 66ec396..640bf44 100644
--- a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
+++ b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -25,7 +25,6 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.SCBEngine;
@@ -43,12 +42,17 @@ import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.netflix.config.DynamicPropertyFactory;
+
import io.vertx.core.Context;
-import io.vertx.core.Vertx;
public final class InvokerUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(InvokerUtils.class);
+ private static boolean enableEventLoopBlockingCallCheck =
+ DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.invocation.enableEventLoopBlockingCallCheck", true).get();
+
@SuppressWarnings({"unchecked"})
public static <T> T syncInvoke(String microserviceName, String microserviceVersion, String transport,
String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType) {
@@ -134,11 +138,7 @@ public final class InvokerUtils {
}
public static boolean isInEventLoop() {
- return isInEventLoop(Vertx.currentContext());
- }
-
- public static boolean isInEventLoop(@Nullable Context context) {
- return context != null && context.isEventLoopContext();
+ return Context.isOnEventLoopThread();
}
/**
@@ -148,7 +148,7 @@ public final class InvokerUtils {
*/
public static Response innerSyncInvoke(Invocation invocation) {
try {
- if (isInEventLoop()) {
+ if (enableEventLoopBlockingCallCheck && isInEventLoop()) {
throw new IllegalStateException("Can not execute sync logic in event loop. ");
}
invocation.onStart(null, System.nanoTime());