From 3f244b2cffad49be46f5448cd371f5539567a94e Mon Sep 17 00:00:00 2001 From: redkale Date: Mon, 10 Apr 2023 08:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSncpServlet=E7=9A=84asm?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/redkale/net/sncp/SncpServlet.java | 2 +- .../java/org/redkale/test/sncp/SncpTest.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/redkale/net/sncp/SncpServlet.java b/src/main/java/org/redkale/net/sncp/SncpServlet.java index 647ed8f2f..dbe0a6944 100644 --- a/src/main/java/org/redkale/net/sncp/SncpServlet.java +++ b/src/main/java/org/redkale/net/sncp/SncpServlet.java @@ -604,7 +604,7 @@ public class SncpServlet extends Servlet for (int[] j : codes) { mv.visitVarInsn(j[0], j[1]); } - mv.visitMethodInsn(resourceType.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL, serviceImpTypeName, method.getName(), Type.getMethodDescriptor(method), resourceType.isInterface()); + mv.visitMethodInsn(serviceImplClass.isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL, serviceImpTypeName, method.getName(), Type.getMethodDescriptor(method), serviceImplClass.isInterface()); store++; } if (method.getReturnType() != void.class) { diff --git a/src/test/java/org/redkale/test/sncp/SncpTest.java b/src/test/java/org/redkale/test/sncp/SncpTest.java index f364d0a38..f6e443efd 100644 --- a/src/test/java/org/redkale/test/sncp/SncpTest.java +++ b/src/test/java/org/redkale/test/sncp/SncpTest.java @@ -8,6 +8,7 @@ package org.redkale.test.sncp; import java.net.InetSocketAddress; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.Test; import org.redkale.boot.*; import org.redkale.convert.bson.*; import org.redkale.net.*; @@ -26,7 +27,7 @@ public class SncpTest { private static int port = 0; - private static int port2 = 4240; + private static int port2 = 1; private static final String protocol = "SNCP.TCP"; // TCP UDP @@ -38,7 +39,16 @@ public class SncpTest { private static SncpRpcGroups rpcGroups; - public static void main(String[] args) throws Exception { + private boolean main; + + public static void main(String[] args) throws Throwable { + SncpTest test = new SncpTest(); + test.main = true; + test.run(); + } + + @Test + public void run() throws Exception { LoggingBaseHandler.initDebugLogConfig(); application = Application.create(true); rpcGroups = application.getSncpRpcGroups(); @@ -60,7 +70,7 @@ public class SncpTest { } } - private static void runClient() throws Exception { + private void runClient() throws Exception { InetSocketAddress addr = new InetSocketAddress(myhost, port); rpcGroups.computeIfAbsent("client", protocol.endsWith(".UDP") ? "UDP" : "TCP").putAddress(addr); if (port2 > 0) { @@ -91,7 +101,7 @@ public class SncpTest { System.out.println("bean: " + callbean); System.out.println("\r\n\r\n\r\n\r\n---------------------------------------------------"); Thread.sleep(200); - final int count = 40; + final int count = main ? 40 : 11; final CountDownLatch cld = new CountDownLatch(count); final AtomicInteger ai = new AtomicInteger(); long s = System.currentTimeMillis(); @@ -127,7 +137,9 @@ public class SncpTest { cld.await(); System.out.println("---并发" + count + "次耗时: " + (System.currentTimeMillis() - s) / 1000.0 + "s"); if (count == 1) { - System.exit(0); + if (main) { + System.exit(0); + } return; } Thread.sleep(200); @@ -140,7 +152,6 @@ public class SncpTest { }); cld2.await(); System.out.println("---全部运行完毕---"); - System.exit(0); } private static void runServer() throws Exception {