修复SncpServlet的asm问题

This commit is contained in:
redkale
2023-04-10 08:27:57 +08:00
parent 3178221c44
commit 3f244b2cff
2 changed files with 18 additions and 7 deletions

View File

@@ -604,7 +604,7 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
for (int[] j : codes) { for (int[] j : codes) {
mv.visitVarInsn(j[0], j[1]); 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++; store++;
} }
if (method.getReturnType() != void.class) { if (method.getReturnType() != void.class) {

View File

@@ -8,6 +8,7 @@ package org.redkale.test.sncp;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
import org.redkale.boot.*; import org.redkale.boot.*;
import org.redkale.convert.bson.*; import org.redkale.convert.bson.*;
import org.redkale.net.*; import org.redkale.net.*;
@@ -26,7 +27,7 @@ public class SncpTest {
private static int port = 0; private static int port = 0;
private static int port2 = 4240; private static int port2 = 1;
private static final String protocol = "SNCP.TCP"; // TCP UDP private static final String protocol = "SNCP.TCP"; // TCP UDP
@@ -38,7 +39,16 @@ public class SncpTest {
private static SncpRpcGroups rpcGroups; 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(); LoggingBaseHandler.initDebugLogConfig();
application = Application.create(true); application = Application.create(true);
rpcGroups = application.getSncpRpcGroups(); 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); InetSocketAddress addr = new InetSocketAddress(myhost, port);
rpcGroups.computeIfAbsent("client", protocol.endsWith(".UDP") ? "UDP" : "TCP").putAddress(addr); rpcGroups.computeIfAbsent("client", protocol.endsWith(".UDP") ? "UDP" : "TCP").putAddress(addr);
if (port2 > 0) { if (port2 > 0) {
@@ -91,7 +101,7 @@ public class SncpTest {
System.out.println("bean " + callbean); System.out.println("bean " + callbean);
System.out.println("\r\n\r\n\r\n\r\n---------------------------------------------------"); System.out.println("\r\n\r\n\r\n\r\n---------------------------------------------------");
Thread.sleep(200); Thread.sleep(200);
final int count = 40; final int count = main ? 40 : 11;
final CountDownLatch cld = new CountDownLatch(count); final CountDownLatch cld = new CountDownLatch(count);
final AtomicInteger ai = new AtomicInteger(); final AtomicInteger ai = new AtomicInteger();
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
@@ -127,7 +137,9 @@ public class SncpTest {
cld.await(); cld.await();
System.out.println("---并发" + count + "次耗时: " + (System.currentTimeMillis() - s) / 1000.0 + "s"); System.out.println("---并发" + count + "次耗时: " + (System.currentTimeMillis() - s) / 1000.0 + "s");
if (count == 1) { if (count == 1) {
System.exit(0); if (main) {
System.exit(0);
}
return; return;
} }
Thread.sleep(200); Thread.sleep(200);
@@ -140,7 +152,6 @@ public class SncpTest {
}); });
cld2.await(); cld2.await();
System.out.println("---全部运行完毕---"); System.out.println("---全部运行完毕---");
System.exit(0);
} }
private static void runServer() throws Exception { private static void runServer() throws Exception {