Avoiding pitfalls with Java streams, concurrency, HTTP requests and more
summary
Comparator objects get created repeatedly, doubling sort cost vs a single static comparator (JMH shows ~2x speedup), a non-atomic check-then-act on a ConcurrentHashMap loses accounts under concurrency and is fixed with computeIfAbsent, using side-effecting Stream operations can be optimized away or break under parallel streams causing lost updates, and a Spring HTTP interceptor that throws without calling response.close causes connection leaks. Open-source Pinpoint rules and IDE/Sonar checks detect these patterns and found a handful of real production occurrences.
AI-written summary · about
chapters (10)
- 0:00Introduction and welcome
- 1:26Interactive quiz setup
- 5:06Java streams comparator pitfalls
- 13:12Concurrency bug in concurrent map
- 13:32Java streams side effects smell
- 18:28Stream side effects optimization surprise
- 23:54Parallel stream concurrency issues
- 27:53HTTP request interceptor exception handling
- 32:27Approach to prevent production issues
- 33:51Wrap-up and key takeaways
