You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2021/09/02 13:33:33 UTC

[GitHub] [incubator-shenyu] ichenhe opened a new issue #2012: Spring Cloud - Wrong context path

ichenhe opened a new issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012


   ## Describe the bug
   
   It seems that spring cloud dependence failed to register context path correctly, caused the actual path that shenyu visit is very strange.
   
   ## Environment
   
   - ShenYu version(s): 2.4.0
   
   ## Steps to reproduce
   
   1. Add dependence to my service: `implementation("org.apache.shenyu:shenyu-spring-boot-starter-client-springcloud:${Const.shenYuVersion}")`
   2. Add properties:
   ```yaml
   shenyu:
     client:
       registerType: nacos
       props:
         contextPath: "/"
         nacosNameSpace: Shenyu
         isFull: false
   ```
   3. Add annotation to class and function.
   ```kotlin
   @RestController
   @ShenyuSpringCloudClient(path = "/users")
   internal class UserController(
       private val userService: UserService,
       private val watchfacePermissionService: WatchfacePermissionService,
   ) : IUserController {
   
       @ShenyuSpringCloudClient(path = "/hello")
       override fun hello(): String {
           return "Hello"
       }
   }
   ```
   
   Then, send a request to shenyu: `http://localhost:7000/users/hello`.
   
   ## Expected behavior
   
   Shenyu should redirect to `http://xxx.xxx.xx.xx:7010/users/hello`.
   
   But the actual is `http://192.168.50.20:7010ers/hello`.
   
   ---
   
   I checked the context_path's rules, there is a newly added:
   
   ![](https://user-images.githubusercontent.com/10266066/131852167-58072435-e05a-47bb-b770-c7a346bf5556.png)
   
   After several attempts, I really can't understand the specific behavior of this plugin —— No matter what I fill in, I can't achieve the expected behavior.
   
   Finally, I turned off the plugin (or delete this rule) and everything was fine.
   
   ---
   
   So, does this tool misunderstand the path I set? Or are there other approch for this situation where context_path is not required?
   
   ## Debug logs
   
   ```
   INFO 46443 --- [ctor-http-nio-3] o.a.s.plugin.base.AbstractShenyuPlugin   : context_path selector success match , selector name :/context-path/
   INFO 46443 --- [ctor-http-nio-3] o.a.s.plugin.base.AbstractShenyuPlugin   : context_path rule success match , rule name :/context-path/
   INFO 46443 --- [ctor-http-nio-3] o.a.s.plugin.base.AbstractShenyuPlugin   : springCloud selector success match , selector name :/
   INFO 46443 --- [ctor-http-nio-3] o.a.s.plugin.base.AbstractShenyuPlugin   : springCloud rule success match , rule name ://users/**
   INFO 46443 --- [ctor-http-nio-3] o.a.s.plugin.httpclient.WebClientPlugin  : The request urlPath is http://192.168.50.20:7010ers/hello, retryTimes is 0
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911852906


   Check your configuration, you put the wrong contextPath.By the way, if your request path don't need `context-path`, just set empty string,please don't set `"/"`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe closed issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe closed issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912948638


   @ichenhe if you set the `context_path` attribute to an empty string like the following:
   
   application `context path` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132091206-f43d6b6c-c5fc-48e5-8b41-54990caa06ea.png)
   
   then `context path` is empty:
   ![image](https://user-images.githubusercontent.com/2174082/132091232-bc1dcb6c-8da3-4e0c-9a1d-06d978308ee1.png)
   
   the `divide` selector can be set like the following:
   
   `test/**` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091145-952d6d6b-beae-4487-9e29-fc2815f7d3cf.png)
   
   `order` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091154-1ffa23e8-0806-4aa9-8379-6895cd5f1d96.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912940561


   Hello @ichenhe , i had tried many times, if you want to use registy center such as `nacos` and `zookeeper`, you have to set the `context-path` in your application without any special characters, you can set as your application's name.And when you send request, you should add `context-path` before your path.If you have any question,please tell us.
   
   At last, thanks a lot for your report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911863062


   @qicz Maybe I didn't fully understand your words.
   According to your statement, it seems that it should be `sers` in the end, but actual is `ers`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911888634


   Thanks a lot, this bug will be fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912946625


   maybe help you @ichenhe 
   
   Springboot backend: `http://192.168.199.196:8189/order/findById?id=123` and `http://192.168.199.196:8189/test/findByUserId?userId=123`
   
   `context path` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090624-ff06d3f3-ef21-4db4-a181-8549606decf8.png)
   
   `context path` rule setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090640-ea55b780-89e4-4d13-80a1-100660f3885a.png)
   
   `divide` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090702-082a3756-a26c-48e9-ac17-f30c11004c08.png)
   
   `divide` rule `order` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090709-429f0b77-4735-46eb-a561-c324be76b738.png)
   
   `divide` rule `test/**` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090722-1c0e5126-2670-471e-80f8-18c610650527.png)
   
   `order` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090729-a3c1e2e6-d56a-4619-a92d-9021e6660fe0.png)
   
   `test/**` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090733-1c1f97ec-56c2-43cb-a9c1-11cfecb82645.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912948638


   @ichenhe if you set the `context_path` attribute to an empty string, the `divide` selector can be set like follow:
   
   application `context path` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132091206-f43d6b6c-c5fc-48e5-8b41-54990caa06ea.png)
   
   `test/**` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091145-952d6d6b-beae-4487-9e29-fc2815f7d3cf.png)
   
   `order` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091154-1ffa23e8-0806-4aa9-8379-6895cd5f1d96.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912132946


   > @qicz Maybe I didn't fully understand your words.
   > According to your statement, it seems that it should be `sers` in the end, but actual is `ers`.
   
   the rule `//users/**` first char `/` can be the default, the result is `sers`  after removing the start 3 chars, so my description was wrong.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912944050


   @KevinClair Yes, I understood.
   
   The point is, I don't want context-path. That's why I set it to '/', but it failed.
   
   Maybe it's a little weird. Because I may expose more than one name for a service (e.g. users and messages), but context-path can only have one value. So I prefer `@ShenyuSpringCloudClient(path='')` to set the prefix.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912940975


   @KevinClair So, I must set a context_path. There is no way to approach root request.
   Did I understand it correctly?
   
   If yes, how about qicz's PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912297321


   #2017 fixed this bug.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912946625


   maybe can help you @ichenhe 
   
   `context path` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090624-ff06d3f3-ef21-4db4-a181-8549606decf8.png)
   
   `context path` rule setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090640-ea55b780-89e4-4d13-80a1-100660f3885a.png)
   
   `divide` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090702-082a3756-a26c-48e9-ac17-f30c11004c08.png)
   
   `divide` rule `order` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090709-429f0b77-4735-46eb-a561-c324be76b738.png)
   
   `divide` rule `test/**` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090722-1c0e5126-2670-471e-80f8-18c610650527.png)
   
   `order` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090729-a3c1e2e6-d56a-4619-a92d-9021e6660fe0.png)
   
   `test/**` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090733-1c1f97ec-56c2-43cb-a9c1-11cfecb82645.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912299058


   @qicz thanks. So I should still set `context_path` attribute to an empty string?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912943306


   For example,the context-path is '/http'
   By springmvc, your request's path is `http://localhost:8080/test`.
   By shenyu, your request's path is `http://localhost:9195/http/test`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912940561


   Hello @ichenhe , i had tried many times, if you want to use registy center such as `nacos` and `zookeeper`, you have to set the `context-path` in your application without any special characters, you can set as your application's name.And when you send request, you should add `context-path` before your path.
   
   If you have any question, please tell us or i will close it.
   
   At last, thanks a lot for your report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912950074


   > @ichenhe if you set the `context_path` attribute to an empty string like the following:
   > 
   > application `context path` setting:
   > ![image](https://user-images.githubusercontent.com/2174082/132091206-f43d6b6c-c5fc-48e5-8b41-54990caa06ea.png)
   > 
   > then `context path` is empty:
   > ![image](https://user-images.githubusercontent.com/2174082/132091232-bc1dcb6c-8da3-4e0c-9a1d-06d978308ee1.png)
   > 
   > the `divide` selector can be set like the following:
   > 
   > `test/**` selector and rule:
   > ![image](https://user-images.githubusercontent.com/2174082/132091145-952d6d6b-beae-4487-9e29-fc2815f7d3cf.png)
   > 
   > `order` selector and rule:
   > ![image](https://user-images.githubusercontent.com/2174082/132091154-1ffa23e8-0806-4aa9-8379-6895cd5f1d96.png)
   
   maybe this is what you wantted.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911855359


   @KevinClair As I mentioned, you can't set an empty string, otherwise an exception will occur. So what should be the correct value?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912951480


   I think the core problem has been solved, since @qicz improved the validator.
   
   As for other problems, I think I need some time to learn and practice. Thank you for @qicz 's pr & explanation and @KevinClair 's debugging.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911879782


   @KevinClair `contextPath: ""`
   
   exception:
   
   <details>
   <summary>Click to expand</summary>
   
   ```
   Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-33" Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-35" Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-37" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-38" Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-36" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-34" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   WARNING: An illegal reflective access operation has occurred
   WARNING: Illegal reflective access by org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook$TakeoverOtherHooksThread (file:/Users/chenhe/.gradle/caches/modules-2/files-2.1/org.apache.shenyu/shenyu-client-core/2.4.0/e0e3fce323397845aeb5214345dc48c328aa7796/shenyu-client-core-2.4.0.jar) to field java.lang.ApplicationShutdownHooks.hooks
   WARNING: Please consider reporting this to the maintainers of org.apache.shenyu.client.core.shutdown.ShenyuClientShutdownHook$TakeoverOtherHooksThread
   WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
   WARNING: All illegal access operations will be denied in a future release
   java.lang.StringIndexOutOfBoundsException: String index out of range: -1
   	at java.base/java.lang.String.substring(String.java:1841)
   	at org.apache.shenyu.register.client.nacos.NacosClientRegisterRepository.persistInterface(NacosClientRegisterRepository.java:95)
   	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientMetadataExecutorSubscriber.executor(ShenyuClientMetadataExecutorSubscriber.java:67)
   	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:41)
   	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
   	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
   	at java.base/java.lang.Thread.run(Thread.java:834)
   ```
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912946625


   maybe help you @ichenhe 
   
   `context path` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090624-ff06d3f3-ef21-4db4-a181-8549606decf8.png)
   
   `context path` rule setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090640-ea55b780-89e4-4d13-80a1-100660f3885a.png)
   
   `divide` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090702-082a3756-a26c-48e9-ac17-f30c11004c08.png)
   
   `divide` rule `order` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090709-429f0b77-4735-46eb-a561-c324be76b738.png)
   
   `divide` rule `test/**` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090722-1c0e5126-2670-471e-80f8-18c610650527.png)
   
   `order` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090729-a3c1e2e6-d56a-4619-a92d-9021e6660fe0.png)
   
   `test/**` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090733-1c1f97ec-56c2-43cb-a9c1-11cfecb82645.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912948638


   @ichenhe if you set the `context_path` attribute to an empty string, the `divide` selector can be setting like follow:
   
   `test/**` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091145-952d6d6b-beae-4487-9e29-fc2815f7d3cf.png)
   
   `order` selector and rule:
   ![image](https://user-images.githubusercontent.com/2174082/132091154-1ffa23e8-0806-4aa9-8379-6895cd5f1d96.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911848812


   see #2014 , the `context path` is `/**` 3 chars, the `rule` is `//users/**` , cut the first 3 chars is `sers` so urlPath changed to `http://192.168.50.20:7010ers/hello`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912941914


   > What do you mean `root request`?
   
   No context path. Shenyu redirect the request AS IS.
   http://apigetway.com/users/hello  ->  http://backend.com/users/hello
   
   Not -> http://backend.com/{context_path}/users/hello


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] ichenhe commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
ichenhe commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912949025


   @qicz I don't understand what divide is for. For now, simply deleting the default generated context_path rule can solve the problem. This is simpler than your plan.
   
   I opened this issue because I wonder why the plugin generates this wrong rule. (now KevinClair said I have to set a valid context-path if I use registy center)
   
   So the finally problem is, does the plugin allow me to set an empty context-path and automatically generate the correct rules. (Even though I know how to correct the wrong rules)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912363787


   > @qicz thanks. So I should still set `context_path` attribute to an empty string?
   
   #2017 just validate the `context path` is valid or invalid.  if the `context path` is invalid will respond to an error message. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912946625


   maybe can help you @ichenhe 
   
   ![image](https://user-images.githubusercontent.com/2174082/132090624-ff06d3f3-ef21-4db4-a181-8549606decf8.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090640-ea55b780-89e4-4d13-80a1-100660f3885a.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090702-082a3756-a26c-48e9-ac17-f30c11004c08.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090709-429f0b77-4735-46eb-a561-c324be76b738.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090722-1c0e5126-2670-471e-80f8-18c610650527.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090729-a3c1e2e6-d56a-4619-a92d-9021e6660fe0.png)
   ![image](https://user-images.githubusercontent.com/2174082/132090733-1c1f97ec-56c2-43cb-a9c1-11cfecb82645.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912949931


   > @qicz I don't understand what divide is for. For now, simply deleting the default generated context_path rule can solve the problem. This is simpler than your plan.
   > 
   > I opened this issue because I wonder why the plugin generates this wrong rule. (now KevinClair said I have to set a valid context-path if I use registy center)
   > 
   > So the finally problem is, does the plugin allow me to set an empty context-path and automatically generate the correct rules. (Even though I know how to correct the wrong rules)
   
   `context path` can manage a class of applications without having to configure many selectors in `divide`, which is probably a goal. Such as `/dubbo` dubbo application,  `/ springcloud` springcloud application.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912363787


   > @qicz thanks. So I should still set `context_path` attribute to an empty string?
   
   #2017 just validate the `context path` valid or invalid.  if the `context path` is invalid will respond to an error message. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-911875565


   > @KevinClair As I mentioned, you can't set an empty string, otherwise an exception will occur. So what should be the correct value?
   
   Can you show me the exception?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] qicz edited a comment on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
qicz edited a comment on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912946625


    @ichenhe  maybe help you.
   
   Springboot backend: `http://192.168.199.196:8189/order/findById?id=123` and `http://192.168.199.196:8189/test/findByUserId?userId=123`
   
   `context path` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090624-ff06d3f3-ef21-4db4-a181-8549606decf8.png)
   
   `context path` rule setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090640-ea55b780-89e4-4d13-80a1-100660f3885a.png)
   
   `divide` selector setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090702-082a3756-a26c-48e9-ac17-f30c11004c08.png)
   
   `divide` rule `order` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090709-429f0b77-4735-46eb-a561-c324be76b738.png)
   
   `divide` rule `test/**` setting:
   ![image](https://user-images.githubusercontent.com/2174082/132090722-1c0e5126-2670-471e-80f8-18c610650527.png)
   
   `order` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090729-a3c1e2e6-d56a-4619-a92d-9021e6660fe0.png)
   
   `test/**` rule result:
   ![image](https://user-images.githubusercontent.com/2174082/132090733-1c1f97ec-56c2-43cb-a9c1-11cfecb82645.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-shenyu] KevinClair commented on issue #2012: Spring Cloud - Wrong context path

Posted by GitBox <gi...@apache.org>.
KevinClair commented on issue #2012:
URL: https://github.com/apache/incubator-shenyu/issues/2012#issuecomment-912941655


   What do you mean `root request`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org