Skip to content

ConnectionFieldTypeVisitor.ConnectionDataFetcher.adapt throws IndexOutOfBoundsException when container is empty #775

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

Closed
jimador opened this issue Aug 17, 2023 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@jimador
Copy link

jimador commented Aug 17, 2023

The ConnectionFieldTypeVisitor.ConnectionDataFetcher.adapt method throws an IndexOutOfBoundsException when the container parameter is empty (e.g. an empty Spring Data Window). adapter.getContent(emptyWindowObject) will return an empty collection which makes nodes and edges empty lists. When edges.get(0) is called, we get an exception thrown - IndexOutOfBoundsException: Index 0 out of bounds for length 0.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 17, 2023
@manishtulsiani
Copy link

Hi @jimador, we had the same error in our project when returning an empty container. Turns out, in this case, if you return null instead of empty container, the ConnectionFieldTypeVisitor.ConnectionDataFetcher.adapt maps it to an empty connection as seen here

@rstoyanchev rstoyanchev self-assigned this Sep 1, 2023
@rstoyanchev rstoyanchev added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 1, 2023
@rstoyanchev rstoyanchev added this to the 1.2.3 milestone Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants