diff --git a/powerjob-remote/powerjob-remote-framework/src/main/java/tech/powerjob/remote/framework/engine/impl/ActorFactory.java b/powerjob-remote/powerjob-remote-framework/src/main/java/tech/powerjob/remote/framework/engine/impl/ActorFactory.java index 656b71b3..f1628118 100644 --- a/powerjob-remote/powerjob-remote-framework/src/main/java/tech/powerjob/remote/framework/engine/impl/ActorFactory.java +++ b/powerjob-remote/powerjob-remote-framework/src/main/java/tech/powerjob/remote/framework/engine/impl/ActorFactory.java @@ -61,8 +61,8 @@ class ActorFactory { } HandlerLocation handlerLocation = new HandlerLocation() - .setRootPath(rootPath) - .setMethodPath(handlerMethodAnnotation.path()); + .setRootPath(suitPath(rootPath)) + .setMethodPath(suitPath(handlerMethodAnnotation.path())); HandlerInfo handlerInfo = new HandlerInfo() .setAnno(handlerMethodAnnotation) @@ -72,4 +72,11 @@ class ActorFactory { } return ret; } + + static String suitPath(String path) { + if (path.startsWith("/")) { + return path.replaceFirst("/", ""); + } + return path; + } } diff --git a/powerjob-remote/powerjob-remote-framework/src/test/java/tech/powerjob/remote/framework/engine/impl/ActorFactoryTest.java b/powerjob-remote/powerjob-remote-framework/src/test/java/tech/powerjob/remote/framework/engine/impl/ActorFactoryTest.java index 514d8e19..7e80d2ae 100644 --- a/powerjob-remote/powerjob-remote-framework/src/test/java/tech/powerjob/remote/framework/engine/impl/ActorFactoryTest.java +++ b/powerjob-remote/powerjob-remote-framework/src/test/java/tech/powerjob/remote/framework/engine/impl/ActorFactoryTest.java @@ -24,4 +24,12 @@ class ActorFactoryTest { ActorFactory.load(Lists.newArrayList(new TestActor())); } + @Test + void testSuitPath() { + final String testPath1 = ActorFactory.suitPath("/test"); + final String testPath2 = ActorFactory.suitPath("test"); + log.info("[ActorFactoryTest] testPath1: {}, testPath2: {}", testPath1, testPath2); + assert testPath1.equals(testPath2); + } + } \ No newline at end of file