Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

got error message : 'fromIndex > toIndex' after calling '/service/list' #4477

Closed
zcz3313 opened this issue Dec 14, 2020 · 1 comment · Fixed by #4486
Closed

got error message : 'fromIndex > toIndex' after calling '/service/list' #4477

zcz3313 opened this issue Dec 14, 2020 · 1 comment · Fixed by #4486
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Milestone

Comments

@zcz3313
Copy link

zcz3313 commented Dec 14, 2020

Describe the bug
got error message : 'fromIndex > toIndex' after calling '/service/list'

Expected behavior
got empty data list if there is no data that meets the conditions

Acutally behavior
got error

How to Reproduce
Steps to reproduce the behavior:
1.I have 3 services on nacos.
2.I want to get all service list using 'getServicesOfServer(int pageNo, int pageSize)' api of nacos client.
3.first, I call this method using params: pageNo = 1, pageSize = 10, this works fine.
4.then, I call this method using params: pageNo = 2, pageSize = 10, I got the error above.

I have seen the source code of https://github.com/alibaba/nacos/blob/1.4.0/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java, and I think the reason of the error is line 263.

In this case, start = 10 and end = 3 when pageNo = 2, pageSize = 10.
then 'serviceNameList.subList(start, end)' throws an error.

Additional context
my client fake client code is:

public void getNacosServiceList(int pageNo) {
    ListView<String> listView = nacosDiscoveryProperties.namingServiceInstance().getServicesOfServer(pageNo, 10);
    if (listView.getData().size() <= 0) {
        return;
    }
    for (int i = 0; i < listView.getData().size(); i++) {
        String nacosService = listView.getData().get(i);
        //do something
    }
    getNacosServiceList(pageNo + 1);
}
@KomachiSion KomachiSion added kind/bug Category issues or prs related to bug. good first issue Good for newcomers labels Dec 14, 2020
@KomachiSion KomachiSion added this to the 1.4.1 milestone Dec 14, 2020
@haoyann
Copy link
Collaborator

haoyann commented Dec 14, 2020

@i will solve it@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants