Breaking Scala's Nil with Java Reflection
Briefly

Breaking Scala's Nil with Java Reflection
"The exception occurred inside a list transformation, during the execution of map. The full stack trace was longer and passed through several abstraction layers, so I prepared a minimal test case to reproduce the issue."
"The real cause was hiding much deeper - not in Scala itself, but in the JVM. Somewhere beneath all the declarative elegance was something capable of breaking even a fundamental assumption: that Nil is a singleton."
A bug in a Spring-based Scala project was traced to Java reflection used in Spring Data MongoDB, which broke Scala's Nil singleton. The issue manifested as a NoSuchElementException when invoking head on an empty list during a transformation. Initial tests did not reproduce the error, leading to confusion. The root cause was found in the MongoDB support module of Spring Data MongoDB, exposing a deeper issue with JVM behavior that contradicted Scala's assumptions about Nil being a singleton.
Read at Medium
Unable to calculate read time
[
|
]