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

Exception when deleting project #169

Open
Death111 opened this issue Nov 9, 2023 · 1 comment
Open

Exception when deleting project #169

Death111 opened this issue Nov 9, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Death111
Copy link
Collaborator

Death111 commented Nov 9, 2023

Following exception happened when deleting an project:

java.lang.IllegalArgumentException: Illegal Capacity: -1
	at java.base/java.util.ArrayList.<init>(ArrayList.java:158)
	at de.doubleslash.keeptime.controller.Controller.adaptProjectIndexesAfterRemoving(Controller.java:304)
	at de.doubleslash.keeptime.controller.Controller.deleteProject(Controller.java:194)
	at de.doubleslash.keeptime.REST_API.controller.ProjectController.deleteProject(ProjectController.java:111)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)

image

final List<Project> changedProjects = new ArrayList<>(size - removedIndex);

Logic seems wrong: List is initialized with a capacity based on the sorting Index - which does not make sense?

@Death111 Death111 added the bug Something isn't working label Nov 9, 2023
@Death111
Copy link
Collaborator Author

Death111 commented Nov 9, 2023

Most likely this cannot happen with a valid database state. If I have e.g. 13 projects, the highest sort index should be 12. So when the logic "size - removedIndex" is executed (13-12) will instantiate a list with initial capacity 1.
(It did occure in an invalid state with some REST API experiments which created "invalid" projects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant