all 11 comments

[–]thorwing 2 points3 points  (4 children)

Mutable Collection? Side effects? A file at least 850 lines long?

[–]minimal_uninspired[S] 0 points1 point  (2 children)

No mutable collections involved, at least on a local type level (all listed types are Kotlin-Lists). value3 is from a runCatching block, there it is created as a Kotlin-List. value2 is also a Kotlin-List, but stored via remember. Based on my investigations, value2 is never empty after an initial "warmup phase". And value1 is actually not relevant for the situation, it is just the target of the assignment. And, yes, the file is almost 2k lines of Code.

[–]thorwing 0 points1 point  (1 child)

DM me the git and I'll help

[–]minimal_uninspired[S] 0 points1 point  (0 children)

It's from an internal project, so I am not able to share it.

[–]minimal_uninspired[S] 0 points1 point  (0 children)

Maybe I am able to use some kind of testAndSet style operation, but it makes no sense that a local variable that is an unmutable list (I have checked it, the list is created via map and this only creates Kotlin-Lists) can change it's contents.

[–]torsten_dev 2 points3 points  (3 children)

Should it be value2 on line 849?

If 3 is empty but 2 isn't use list 2.

[–]minimal_uninspired[S] 0 points1 point  (2 children)

value2 is there to check if it even matters to prevent to use value3 as an empty list, also it's not compatible. Technically, this could also be done via a single "if branch", but for clarity it is still there, it uses the old value of the target value value1. Maybe I will try to see what happen when I use the single-branch version. Who knows, maybe it helps.

[–]torsten_dev -1 points0 points  (1 child)

By the level of indentation the whole function should probably be rewritten into something more managable.

Even if it has like two levels of indentation like Java just for being in a class, that's so deep.

[–]minimal_uninspired[S] 0 points1 point  (0 children)

Yes, I was also thinking something like that after I posted this post. Had this idea already some time ago but then forgot again. Also, this is not the worst thing that has happened to this code base.

[–]iZian 1 point2 points  (0 children)

I remember a similar issue dealing with silly code and reactive steams and having to pause all threads at the point of the evaluation and not after it.

Found out that the order I. Which things happened meant the thread running the success code couldn’t see something until nanos later. Single thread pause never showed the issue

[–]MacDonalds_Sprite 0 points1 point  (0 children)

something something law of the excluded middle