Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Ensure that getAll() always returns a mutable list #685
If a box is empty,
@rocboronat That‘s mostly true but that‘s not what this change is about. The current API makes no promises regarding immutability. It promises a java.util.List, which is a mutable container. And in most of the cases, you actually get a mutable list. But if the box is empty, you suddenly get an immutable list. This is bonkers because it turns a compile-time error into a runtime problem.
In my opinion, It‘d be perfectly fine if ObjectBox consistently returned immutable collections. But this would require a change to the public API and the introduction of a proper immutable list type without any mutators. Otherwise the compiler cannot help.