修复Rest将Future<HttpResult<byte[]>>类型用finishJsonFuture格式输出

This commit is contained in:
redkale
2023-04-06 11:07:09 +08:00
parent 5746449cfb
commit 91d7f51678
3 changed files with 10 additions and 10 deletions

View File

@@ -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);

View File

@@ -79,12 +79,12 @@ public abstract class Sncp {
}
//key: actionid
public static LinkedHashMap<Uint128, Method> loadMethodActions(final Class resourceServiceType) {
public static LinkedHashMap<Uint128, Method> loadMethodActions(final Class serviceTypeOrImplClass) {
final List<Method> list = new ArrayList<>();
final List<Method> multis = new ArrayList<>();
final Map<Uint128, Method> 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;
}

View File

@@ -56,7 +56,6 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
this.serviceid = Sncp.serviceid(resourceName, resourceType);
Class serviceImplClass = Sncp.getServiceType(service);
RedkaleClassLoader.putReflectionPublicMethods(serviceImplClass.getName());
for (Map.Entry<Uint128, Method> en : Sncp.loadMethodActions(serviceImplClass).entrySet()) {
SncpActionServlet action;
try {