Skip to main content

Posts

Showing posts with the label Java for Beginners

๐Ÿง  Java Production Trap I’ll Never Forget – Let’s Talk About ConcurrentModificationException

  ๐Ÿ’ฌ “When I was a fresher, I used to wonder: what things should I never do in Java?” That curiosity led me to explore tons of weird bugs and war stories people had faced in production. Some were scary, some silly — but all of them were super valuable to understand deeply. Today, I’m sharing one such issue I came across. ⚠️ P.S. I didn’t write this code — but I sure learned a lot digging into what went wrong and how it was fixed. ๐Ÿ˜… This post is for the curious devs out there — especially freshers who want to learn the "why" behind Java's behaviors, not just memorize "what to do". ๐Ÿ’ฅ The Problem: ConcurrentModificationException in a Simple Loop ๐Ÿ“Environment: This happened in a Spring Boot microservice deployed on OpenShift (Linux-based). Interestingly, it didn’t throw any error in the developer's local Windows machine during testing. But in prod? BOOM. ๐Ÿ’ฃ Here’s the actual buggy code snippet: List<String> users = getActiveUsers(); // ...