From 91d7f51678ff0d930748ef1c347122b918c23fd2 Mon Sep 17 00:00:00 2001 From: redkale Date: Thu, 6 Apr 2023 11:07:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRest=E5=B0=86Future>=E7=B1=BB=E5=9E=8B=E7=94=A8finishJsonFuture=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/redkale/net/http/Rest.java | 11 ++++++----- src/main/java/org/redkale/net/sncp/Sncp.java | 8 ++++---- src/main/java/org/redkale/net/sncp/SncpServlet.java | 1 - 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/redkale/net/http/Rest.java b/src/main/java/org/redkale/net/http/Rest.java index 277d34635..f8b1177b6 100644 --- a/src/main/java/org/redkale/net/http/Rest.java +++ b/src/main/java/org/redkale/net/http/Rest.java @@ -3165,7 +3165,8 @@ public final class Rest { } else if (CompletionStage.class.isAssignableFrom(returnType)) { mv.visitVarInsn(ASTORE, maxLocals); mv.visitVarInsn(ALOAD, 2); //response - if (returnGenericNoFutureType == HttpScope.class) { + Class returnNoFutureType = TypeToken.typeToClassOrElse(returnGenericNoFutureType, Object.class); + if (returnNoFutureType == HttpScope.class) { if (rcs != null && rcs.length > 0) { mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, newDynName, REST_CONVERT_FIELD_PREFIX + restConverts.size(), convertDesc); @@ -3175,10 +3176,10 @@ public final class Rest { mv.visitVarInsn(ALOAD, maxLocals); mv.visitMethodInsn(INVOKEVIRTUAL, respInternalName, "finishScopeFuture", "(" + stageDesc + ")V", false); } - } else if (returnGenericNoFutureType != byte[].class - && returnGenericNoFutureType != RetResult.class - && returnGenericNoFutureType != HttpResult.class - && returnGenericNoFutureType != File.class + } else if (returnNoFutureType != byte[].class + && returnNoFutureType != RetResult.class + && returnNoFutureType != HttpResult.class + && returnNoFutureType != File.class && !((returnGenericNoFutureType instanceof Class) && (((Class) returnGenericNoFutureType).isPrimitive() || CharSequence.class.isAssignableFrom((Class) returnGenericNoFutureType)))) { if (rcs != null && rcs.length > 0) { mv.visitVarInsn(ALOAD, 0); diff --git a/src/main/java/org/redkale/net/sncp/Sncp.java b/src/main/java/org/redkale/net/sncp/Sncp.java index b8b047e50..b557c2dd7 100644 --- a/src/main/java/org/redkale/net/sncp/Sncp.java +++ b/src/main/java/org/redkale/net/sncp/Sncp.java @@ -79,12 +79,12 @@ public abstract class Sncp { } //key: actionid - public static LinkedHashMap loadMethodActions(final Class resourceServiceType) { + public static LinkedHashMap loadMethodActions(final Class serviceTypeOrImplClass) { final List list = new ArrayList<>(); final List multis = new ArrayList<>(); final Map actionids = new LinkedHashMap<>(); - RedkaleClassLoader.putReflectionPublicMethods(resourceServiceType.getName()); - for (final java.lang.reflect.Method method : resourceServiceType.getMethods()) { + RedkaleClassLoader.putReflectionPublicMethods(serviceTypeOrImplClass.getName()); + for (final java.lang.reflect.Method method : serviceTypeOrImplClass.getMethods()) { if (method.isSynthetic()) { continue; } @@ -116,7 +116,7 @@ public abstract class Sncp { Method old = actionids.get(actionid); if (old != null) { if (old.getDeclaringClass().equals(method.getDeclaringClass())) { - throw new SncpException(resourceServiceType.getName() + " have one more same action(Method=" + method + ", " + old + ", actionid=" + actionid + ")"); + throw new SncpException(serviceTypeOrImplClass.getName() + " have one more same action(Method=" + method + ", " + old + ", actionid=" + actionid + ")"); } continue; } diff --git a/src/main/java/org/redkale/net/sncp/SncpServlet.java b/src/main/java/org/redkale/net/sncp/SncpServlet.java index 9ee7200c9..647ed8f2f 100644 --- a/src/main/java/org/redkale/net/sncp/SncpServlet.java +++ b/src/main/java/org/redkale/net/sncp/SncpServlet.java @@ -56,7 +56,6 @@ public class SncpServlet extends Servlet this.serviceid = Sncp.serviceid(resourceName, resourceType); Class serviceImplClass = Sncp.getServiceType(service); - RedkaleClassLoader.putReflectionPublicMethods(serviceImplClass.getName()); for (Map.Entry en : Sncp.loadMethodActions(serviceImplClass).entrySet()) { SncpActionServlet action; try {